Image copyright Getty Images Image caption The former governor of Jakarta is a Christian in Muslim-majority Indonesia

The former governor of the Indonesian capital, Jakarta, has been released early from his jail term for blasphemy.

Basuki Tjahaja Purnama, known as Ahok, is a Christian and was Jakarta's first non-Muslim governor in 50 years.

But he was convicted of blasphemy in 2017 in a case seen as a test of religious tolerance in the Muslim-majority country.

His case sparked protests in support and condemnation of a politician once tipped for the presidency.

Mr Purnama was released early - for good behaviour - on Thursday morning after serving 20 months of a two-year sentence.

He was greeted by supporters who had gathered outside the detention centre in the hope of meeting him.

Image caption Many supporters were wearing his signature chequered shirt

"My heart told me I had to be here," supporter Heni told the BBC. "I am overjoyed that he is free. I feel like a weight has been lifted from all of us."

Singing songs, some people broke down in tears on hearing the news that he was free.

The politician's eldest son posted a photo of himself with his father on Instagram with the message: "He is back! My dad is free! Thanks everyone for the support."

Blasphemy accusations

Ahok was accused of blasphemy over comments he made during a pre-election campaign in September 2016.

In a speech, he implied that Islamic leaders were trying to trick voters by using a verse in the Koran to argue that Muslims should not vote for a non-Muslim leader.

An edited video of his remarks was widely shared online. It sparked outrage among religious hard-liners who staged regular large rallies calling for him to face trial.

"His prosecution will not be forgotten"

Rebecca Henschke, BBC Indonesia correspondent

In his last public letter from jail, Basuki Tjahaja Purnama made it clear he wanted to start a new chapter in his life. He asked his supporters to now call him by his initials BTP instead of Ahok.

He said he was grateful to God for the time he spent in jail and that if he had stayed in power he would have been "more arrogant, ruder" and hurt more people.

There is now talk of him going on an international speaking tour, creating a YouTube channel and getting married.

But his prosecution will not be forgotten. It changed Indonesia and has had lasting political and social impacts.

It sent a clear message that freedoms of expression and religion in Indonesia are tenuous. And has made it harder for non-Muslims to rise to positions of power in this multi-faith county.

Throughout the trial, Mr Purnama denied wrongdoing, but did apologise for his comments.

The eventual verdict had been met with strong protest. Hard-line Islamic groups who called for the maximum penalty of five years said it was too lenient, but Mr Purnama's supporters said it was too harsh and that he should be acquitted.

Anti-corruption stance

During his term as Jakarta governor from 2014 to 2017, Mr Purnama was known as a straight-talking technocrat.

Image copyright Getty Images Image caption Ahok lost the 2017 election to Anies Rasyid Baswedan

His policies included the setting of minimum wages, calling for free school education and healthcare, reducing traffic congestion and tackling corruption among government officials.

These policies, along with his strong anti-corruption stance, made him very popular in Indonesia and he was tipped as a possible future president.

But in May 2017 he lost the governorship to conservative Muslim candidate Anies Rasyid Baswedan.

Mr Purnama's subsequent imprisonment deeply divided the nation.

"This ruling is sending a clear message to the minorities that they can't play around with the majority or this is what will happen to you," Bivitri Susanti, one of the founders of the Centre of Study for Law and Policy, told the BBC at the time.

Jakarta is a melting pot of many ethnic groups. Despite being a majority Muslim country, Indonesia has a pluralist and multi-faith constitution that recognises six official religions.