MILLIONS of Indonesians went to the polls on February 15th to elect local leaders, from Aceh in the west to Papua in the east. Voters braved the floods and landslides of the rainy season to cast their ballots in a massive exercise of democracy. But the day was dominated by the race for governor of Jakarta, the capital, which had become a test of tolerance in the world’s most populous Muslim country. The embattled incumbent, Basuki Tjahaja Purnama, is a Christian of Chinese descent and thus a member of two tiny minorities.

Islamists tried to turn voters against Mr Basuki, known to all as Ahok, by accusing him of insulting the Koran. On the day, Ahok came first but fell short of an absolute majority, with 43% of the vote, according to unofficial results. This means the election will be decided by a run-off on April 19th. Ahok will face Anies Baswedan, a former education minister, who had been trailing in early polls but ended up taking 40% of the vote. Agus Yudhoyono, the son of a former president, got just 17%. He is now out of the race.

Speaking at his ramshackle campaign headquarters in a leafy neighbourhood, Ahok vowed to fight on. He will have to campaign vigorously to win the run-off. Many Jakartans approve of his urban-renewal schemes, but Islamists are not his only detractors: many oppose the evictions of slum-dwellers that his infrastructure schemes necessitate. Marcus Mietzner of the Australian National University reckons that Ahok will struggle to woo Mr Yudhoyono’s voters, given the “extreme acrimony” between the two camps.

Ahok had been deputy governor, but won an automatic promotion when his predecessor, Joko Widodo, known as Jokowi, stood down to run for president in 2014. He had therefore faced voters only as Jokowi’s running-mate, during the previous election for governor in 2012. Ahok’s re-election had seemed assured until September, when he told a group of fishermen that he understood some of them would not vote for him because they had been deceived into believing that the Koran forbids them to vote for a Christian.

Islamists accused Ahok of denigrating the word of God. They stirred up sectarian outrage further by spreading a doctored clip of the speech on the internet and staged protests to press the authorities to arrest him. Prosecutors eventually charged Ahok with blasphemy. Since December he has appeared in court once a week as the trial proceeds.

On the final day of the campaign, tens of thousands of people gathered at Jakarta’s largest mosque to hear preachers tell them it was God’s will that they cast their ballot for one of the two Muslim candidates. The driving force behind the rally was Rizieq Shihab, the fiery leader of the Islamic Defenders Front (FPI), a vigilante group. Outside the mosque, a giant banner strung across a highway read “Arrest Ahok the blasphemer”. Crowds posed beside placards claiming that it is sinful for Muslims to vote for a kafir, or infidel. Hawkers sold knick-knacks depicting Mr Shihab, the self-proclaimed “imam besar” (supreme leader) of all Indonesia’s Muslims.

But the latest anti-Ahok protest was much smaller than the biggest one, in December, which drew some 500,000 people. This may signal waning support for the Islamist agitators, notably the sanctimonious Mr Shihab, who is caught up in a sexting scandal. Nonetheless, the next two months of campaigning are widely expected to turn even nastier now that the election is a two-man race between a Christian and a Muslim.

Ahok’s opponents seem to have concluded that the surest path to victory is to pander to the sectarians. Both Mr Baswedan and Mr Yudhoyono attended dawn prayers with Mr Shihab at the latest rally, even though moderate Muslim groups had told their members to stay away. Mr Baswedan, who was once feted as a model of tolerance, also gave a speech at FPI’s headquarters in January alongside Mr Shihab, who has twice been convicted of hate speech and used to be shunned by mainstream politicians.

Even if Ahok (pictured) were to win in April, the courts could yet convict him. Blasphemy carries a prison sentence of up to five years, and almost all those charged with it are convicted, presumably because judges are afraid of being harassed by Islamists themselves if they dare to acquit supposed enemies of the faith. In theory, Ahok could still serve as governor while he exhausts the lengthy appeals process. In practice, however, he would come under intense pressure to step down.

Although voters’ continued, if diminished, enthusiasm for Ahok is encouraging, the election has propelled fringe Islamist groups to the forefront of politics. That is also likely to be a feature of the next presidential poll, in 2019. Ahok is a close ally of Jokowi and is backed by the same party. Mr Baswedan, for his part, is backed by Prabowo Subianto, a former army general who narrowly lost the last presidential election. Mr Prabowo is an old-fashioned nationalist, not an Islamist, but he has mobilised the Muslim vote partly by allying with a religious party popular among poor voters. The current configuration of forces suggests that arguments about Islam could play a pivotal role in Indonesian politics for years to come.