There tends to be more focus on why terrorist groups flourish in certain countries than why they fail in others. But Jonathan Tepperman, the managing editor of Foreign Affairs, has just investigated the latter question. In his new book The Fixa series of case studies of government successes ranging from Canada’s welcoming immigration policies to Mexico’s triumph over political gridlock—he examines Indonesia, which boasts the largest Muslim population in the world.

And he makes a striking claim at a time when terrorism seems to be spreading: While small-scale attacks occasionally occur in the country, “The big truth is that Indonesia has come close to effectively eliminating the threat of extremist violence” from Islamic terrorist groups.

Tepperman lists five factors behind Indonesia’s success. (Tepperman’s definition of “success” isn’t everyone’s. Most people would agree that reducing terrorist activity is a good thing, depending on the methods employed. But Tepperman assumes that strengthening liberal, secular, Western-style democracy is also an obvious good. Others might ask: What’s wrong with Indonesians choosing illiberal, Islamist democracy instead? Just because political Islam is popular in a given country doesn’t mean Islamic militancy is.)

The five factors below offer insight into some of the root causes of terrorism and Islamic extremism, but they also reveal the limits of Indonesia as a model—both on its own merits and for other countries.

The story of the Indonesian government’s campaign against extremism, Tepperman told me, is the story of a nation “getting it right at one particular moment in time,” through luck as much as skill and improvisation as much as strategy—and often merely by taking more steps forward than back. It’s a story, in other words, of imperfect and impermanent fixes.

1) Support democracy and pluralism

When Suharto, Indonesia’s dictator for more than three decades, was forced to resign in 1998 amid economic crisis, deadly riots, and political protests, the country’s transition to democracy was immediately threatened. Violence erupted between Christians and Muslims, and separatist insurgencies escalated. “Will Indonesia fall apart?” The Guardian wondered in 1999. It was a fair question to ask about a diverse, destabilized country of 250 million people strewn across thousands of islands.

Indonesia didn’t fall apart. And Tepperman credits the country’s post-Suharto presidents—Abdurrahman Wahid (“Gus Dur”), Megawati Sukarnoputri, Susilo Bambang Yudhoyono (“SBY”), and now Joko Widodo (“Jokowi”)—with keeping the state intact and fortifying democracy, despite their various failings as leaders. Gus Dur, for example, defended the rights of ethnic and religious minorities; Megawati and SBY sought to minimize the role of the military and religion in politics.

These leaders showed “the Indonesian people that democracy is an attractive alternative [to] not just military rule, but Islamic rule as well,” Tepperman told me. They demonstrated that “democracy works.”

The Indonesia expert Sidney Jones made a similar point to my colleague Edward Delman earlier this year, in explaining why relatively few Indonesians are joining ISIS. “Indonesia is a country that doesn’t have a repressive government, is not under occupation, it’s politically stable, so there’s no social unrest or conflict, and the Muslims aren’t a persecuted minority,” she said.

2) Adopt parts of the Islamists’ political agenda

Indonesia’s most conservative Islamist political parties haven’t performed well at the polls in recent years. Tepperman argues that this is in part because SBY undermined their appeal after elections in 2004, when a Muslim Brotherhood-style party made a strong showing. SBY acknowledged that the Islamist party’s twin campaign promises—reducing poverty and combating corruption—were urgent tasks in Indonesia, adopted the agenda as his own, and implemented policies as president to address them (whether those policies succeeded is debatable). Indonesia’s current president has focused on similar issues. “To deal with radicalism and extremism, we need to deal with economic inequality,” Jokowi told Tepperman in 2014.

Hard-line Islamist parties must also contend with a “tolerant,” eclectic version of Islam that has been present in Indonesia since the religion first came to the Southeast Asian island in the 13th century, via Arab and Indian traders, Tepperman notes. But he adds that more orthodox Sunni practices from the Middle East have been widely embraced in Indonesia over the last few decades.

Yet while Indonesian Muslims—who constitute nearly 90 percent of the population—now tend to be more openly devout than they were under the largely secular rule of Suharto, few have extremist religious beliefs. Over 70 percent of Indonesian Muslims support making sharia, or Islamic law, the nation’s legal code, according to a 2012 Pew survey—a higher percentage than in Muslim-majority countries like Tunisia and Turkey, but lower than in states such as Iraq and Malaysia. Four percent of Indonesians have a favorable view of ISIS, according to another recent survey. Six percent of Indonesian Muslims say suicide bombing in defense of Islam is often or sometimes justified—a small percentage that has only gotten smaller over the last decade and a half.

“Indonesia’s success against radicalism has nothing to do with secularism,” Tepperman told me. “The country is steadily becoming more pious, and yet it’s becoming less radical at the same time.”

3) Bring Islamist parties into government

“What you see in countries like Egypt, Syria, elsewhere is: The worst thing that you can do to Islamist parties is ban them from government entirely, because that lets them promise everything under the moon, preserve an immaculate reputation, and present themselves as tribunes of the oppressed people,” Tepperman told me.

SBY, by contrast, brought several Islamist parties into his coalition and cabinet—in part to amass sufficient legislative support to govern, but also, Tepperman suspects, to co-opt the Islamists and expose them as ordinary politicians, not saviors. “Sure enough, like you’ve seen in places like Gaza with Hamas and in Egypt with the Muslim Brotherhood, these parties tend not to be very good at actually governing,” Tepperman said. Islamist politicians in Indonesia have, for instance, been busted for taking bribes and even watching porn in the legislature.

4) Go after terrorists hard

Terrorist attacks in Indonesia spiked following Suharto’s fall, culminating in bombings on the island of Bali in 2002 that killed over 200 people. In response, Megawati created a counterterrorism unit called Densus (Detachment) 88 that, with U.S. and Australian assistance, has aggressively targeted militants ever since. (In July, Indonesian security forces killed the country’s most notorious jihadist, Santoso, who had pledged loyalty to ISIS.)

Still, the gains in counterterrorism—terrorist groups have been dismantled, and attacks in the country have declined, if unevenly, since 2002—have come at a cost. Densus 88 has been accused of torturing detainees, killing suspected terrorists when they could have been captured and put on trial, and committing other human-rights violations.

Meanwhile, the threat has not disappeared. In January, ISIS claimed responsibility for attacks in the capital Jakarta that killed four people. And several hundred Indonesians are thought to have traveled to Syria and Iraq to join militant groups, raising the specter of renewed terrorist activity in Indonesia.

Still, Tepperman advised putting that number in perspective. “While there’s now a lot of hand-wringing about ISIS, the number of Indonesians who’ve actually joined the organization is tiny,” he said. “The best estimates are something like 400 or 500 people. And remember, we’re talking about a population which is the fourth-largest in the world and it’s the largest Islamic country in the world. … That represents a smaller number in per-capita terms than the number of Belgians who have joined ISIS.”

5) … But not too hard

“Repression only breeds more extremism,” Tepperman told me. “That was a lesson that Indonesia’s democrats learned under the dark years of dictatorship when they themselves were repressed.” As a result, the Indonesian government has primarily taken a law-enforcement approach to terrorism, tasking the police with countering the threat rather than rely on a military tainted by its affiliation with the Suharto regime. The government holds public trials for terrorism suspects and attempts to rehabilitate convicted terrorists in prison.

“Detachment 88 officers (most of whom are Muslims) often join their terrorist prisoners in prayer,” the Soufan Group, a security consultancy, reported in 2013. “Muslim clerics are also brought in to discuss Islamic theology with the inmates and explain the wider contexts of passages that are often exploited by extremist clerics in pursuit of their violent objectives. ... [Inmates] are subsequently provided with post-prison release assistance, including employment.” Here too, though, the record is mixed. Indonesia’s deradicalization programs have had “limited success,” the Institute for Economics and Peace, which tracks terrorism trends around the world, concluded in 2015.

* * *

The problem with applying these lessons to a country like Saudi Arabia (which has deradicalization programs but not democracy) or Tunisia (which has democracy but the world’s largest delegation of fighters joining ISIS) is that what Tepperman is describing isn’t necessarily a reproducible “fix.” There are no “five” ways to defeat Islamic extremism, but there are ways to try and make sense of Indonesia’s relative tranquility. That’s what Tepperman has done.

“The big truth is that Indonesia has come close to effectively eliminating the threat of extremist violence,” Tepperman writes. An alternative truth is that Indonesia, through complicated and controversial means, has, for the moment, significantly reduced the threat of extremist violence from terrorists. It’s certainly an achievement, but it’s one that lies somewhere between a stopgap and a solution.