Indonesia's President Joko Widodo can look to next year in a far more relaxed way than he faced 2017. At the end of 2016, radical Islamic groups, notably the Islamic Defenders' Front (FPI), staged huge demonstrations in protest at the blasphemy allegedly committed by the governor of Jakarta, Basuki "Ahok" Purnama, an ethnic Chinese.

The protests, capturing the support of hundreds of thousands of Muslims, shook Widodo's confidence and seemed briefly to threaten his own political survival as 2017 approached.

A year later, Purnama is serving a two-year jail sentence following a guilty verdict for blasphemy after he lost a gubernatorial election. On the other hand, FPI chair Habib Rizieq is himself in self-imposed exile in Saudi Arabia to avoid arrest on pornography charges back home.

Moreover, Widodo has defanged another radical Islamic organization, Hizbut Tahrir Indonesia, by banning it. This measure, while deplored by human rights and democracy advocates, has not undermined the president's popularity. Widodo thus seems much more secure now against any Islamic-driven opposition.

The Purnama case was unusual in that the ex-governor had "double minority" status, being both Christian and ethnically Chinese. Because few ethnic Chinese occupy prominent political posts in Indonesia, large-scale Muslim opposition to another double minority target is unlikely. The continuing dominant position that ethnic Chinese business holds in the Indonesian economy, while a source of frustration and anger for Muslims, does not lend itself readily to street protests. Widodo himself is occasionally the target of whispering campaigns claiming fancifully that he is a Chinese or even a communist. But such "black campaigns," which have a long pedigree in Indonesia, will not shake his grip on power.

On the other hand, U.S. President Donald Trump has handed Muslims in Indonesia as elsewhere a new trigger for mobilizing their supporters with his policy on Jerusalem. Whereas the Widodo government has been keen on a Trump visit in recent months, such a visit now would undoubtedly provoke massive Muslim demonstrations, perhaps even rivaling those of 2016. A Trump visit could therefore severely embarrass Widodo at any time before Indonesia's next presidential election in April 2019.

High stakes

But, though Widodo is currently more secure against Muslim opposition, whoever competes with him for the presidency in 2019 will almost certainly adopt some kind of Islamic platform if only to distinguish himself from the 56-year-old incumbent.

Prabowo Subianto, the retired lieutenant-general and former son-in-law of the late President Suharto, did this in 2014 when he stood against Widodo. He will probably repeat this approach in 2019.

He and Widodo are likely to be only two candidates in the next presidential election. Indonesian electoral laws require would-be presidential candidates to be backed by parties that have together won 25% of the votes or hold 20% of seats in the national parliament. Only Widodo and Subianto crossed this threshold in 2014. The next poll will be held at the same time as parliamentary elections so that, very strangely, the 2014 parliamentary results or seat distribution will again apply.

Party leaders will be tempted to support proven electoral performers rather than untried newcomers, even a former president's son such as Agus Harimurti Yudhoyono. He came only third in the Jakarta governorship election.

By contrast, Widodo has proved he can win a presidential election and can also govern the country. The very wealthy Subianto, for his part, has proved that he run Widodo close. Each has a lot of inducements to offer prospective supporters, particularly ministerial portfolios and government contracts. Promises of future rewards made by newcomers will have far less plausibility.

As he reflects on his prospects for 2018 and 2019, Widodo can draw comfort from his recent success in dispatching the troublesome commander of Indonesia's armed forces, General Gatot Nurmantyo. Widodo dismissed him "with honour" several months before he was due to retire. He replaced Nurmantyo with his air force chief of staff, a longstanding Widodo loyalist. A demagogue with impressive charisma, Nurmantyo was widely seen as a possible presidential candidate. Unwisely, he often took public positions that encroached on the authority of ministers, even of Widodo himself.

The chief of police, Tito Karnavian, is another tried and true Widodo loyalist. The president can therefore face a series of regional elections in 2018 and the national elections in 2019 confident that he has the main organs of state security firmly in his grasp. Not only that. Widodo has just acquired a new asset. Setya Novanto, chair of Golkar, the second biggest party which is in a ruling coalition with the Indonesian Democratic Party of Struggle (PDI-P), is to go on trial on corruption charges. He has been replaced by industry minister Airlangga Hartarto.

Golkar is now much more likely to remain within the Widodo fold. Widodo can already count on the largest party, the PDI-P, run by Megawati Sukarnoputri, daughter of Indonesia's first president, Sukarno.

What can go wrong?

The Indonesian economy has grown moderately rather than dramatically in the Widodo era, expanding by an expected 5.1% in 2017. Reliant on commodity exports, it has been put under pressure from recent global price swings. Meanwhile domestic private consumption is patchy. Although annual inflation is rather low at 4%, domestic price levels for key products are often considerably higher than global prices, creating the impression of high living costs. It is still too early to judge when Widodo's big infrastructure initiatives will yield political benefits or boost economic growth.

What is most uncertain for Widodo, however, is the international geopolitical environment in the Trump era. An American war with Iran would have far-reaching effects on Indonesia through the destabilization of the global economy. An American attack on North Korea leading to war on the Korean Peninsula would also have grievous, unpredictable consequences for Indonesia as for most other Asia-Pacific countries. Perhaps it would make sense for Widodo to invite Trump to Indonesia after all.