Preliminary results suggest that Jakarta’s Christian governor, Basuki Tjahaja Purnama (better known as “Ahok”), has failed in his re-election bid, as his trial for “blasphemy” goes on.

Ahok is accused of insulting a Qur’anic verse during a campaign speech. Hard-line Islamist groups have rallied large crowds against him in recent months, yet he was still able to rely on a strong support base, making it a very tight contest. Indeed, the result still came as a shock to many voters, as Ahok won the first round of voting in February.

His rival, Anies Rasiyd Baswedan, a former education minister and a Muslim, is reported to have won 58 per cent of the votes. Official results will be announced early next month.

Ahok congratulated his opponent and in a televised news conference said: “We now will come together and forget this campaign. Jakarta is home for all of us.” Indonesians expressed their surprise at the result on social media, comparing the outcome with the shock results of the US elections and Brexit (Britain’s decision to leave the EU), but Ahok called on his supporters not to dwell on their disappointment.

Earlier this month, during a court appearance to deal with the blasphemy allegations, Ahok said he had been the target of racist and religious attacks since he was elected to public office in 2005. Muslims make up more than 80 per cent of Indonesia’s population, and the election has been seen as a test of Indonesia’s secular identity.