Islamic hardliners outside the Jakarta court cheered and shouted "God is greatest!" as news came through that Basuki Tjahaja Purnama was to be sent to prison, a surprisingly harsh punishment after prosecutors recommended only probation.

Purnama looked calm when the verdict was announced and said he would appeal, as some of his supporters in court burst into tears.

The governor was hauled into court last year to face trial on charges of insulting Islam while campaigning for re-election, in a case critics said was politically motivated.

The trial came after a series of major protests in the capital against the leader, known by his nickname Ahok, that drew hundreds of thousands onto the streets.

His once unassailable opinion poll lead shrank amid the controversy and he lost the race to lead Jakarta last month to a Muslim challenger, a result that fuelled fears Indonesia's moderate brand of Islam is coming under threat from increasingly influential radicals.

AP

The five-judge panel at the Jakarta court found Purnama guilty of blasphemy after a months-long trial.

Announcing the verdict, presiding judge Dwiarso Budi Santiarto said Purnama was "convincingly guilty of committing blasphemy and is sentenced to two years in prison" and ordered him to be detained.

Another judge, Abdul Rosyad, said reasons for the stiff sentence included that "the defendant didn't feel guilt, the defendant's act has caused anxiety and hurt Muslims".

'He has insulted us'

Blasphemy carries a maximum jail term of five years in Indonesia but the verdict was a surprise as judges in Indonesia typically follow the recommendation of prosecutors in criminal cases.

Prosecutors last month urged judges to hand Purnama two years of probation, with a possible one-year jail term if he committed a crime during that period.

"I am disappointed and sad at the verdict," one of his supporters in court, Octa de Queljoe, told AFP. "It is very rare that a verdict is higher than what the prosecutors had asked for."

Outside the court, hundreds of Islamic radicals wearing white Muslim skullcaps celebrated as they heard about the jail sentence.

"Thank God, he should be jailed - this is right. He has insulted us," Bachtiar, 38, who like many Indonesians goes by one name, told AFP.

However some were unhappy Purnama did not receive the maximum sentence.

"We are upset - he should get more than that, he should get five years," said 46-year-old housewife Novareinita Zein.

Related reading Jakarta's Ahok hits out at blasphemy case

The controversy began in September when Purnama, known for his outspoken style, offended Muslims after he quoted a passage from the Koran during his re-election campaign.

He insinuated that his opponents had used a Koranic verse to trick people into voting against him.

An edited version of his speech went viral online, sparking outrage far beyond Jakarta, where Purnama has ruled since his predecessor Joko Widodo became president in late 2014.

Tobias Basuki, an analyst from Jakarta think-tank the Centre for Strategic and International Studies, said previously the saga surrounding Ahok was“a litmus test of Indonesian Islam - are we tolerant or intolerant?"

Before the blasphemy controversy erupted, Purnama enjoyed a large lead in opinion polls due to his determination to clean up traffic-clogged, polluted Jakarta.

He is due to hand over power in the capital to Anies Baswedan in October, a Muslim former education minister who decisively beat him in the April vote.

The trial started in December and dragged on for months, with both the prosecution and defence calling more than 40 witnesses. Purnama's team have accused the prosecution of calling biased witnesses, saying that many were not even present when the alleged blasphemy took place.

Critics want the country’s blasphemy laws overhauled. The legislation was rarely used during the 32-year rule of strongman Suharto, but in recent years it has been exploited to persecute minorities, rights groups say.