JAKARTA, Indonesia — An Indonesian court found the Christian governor of the country’s capital, Jakarta, guilty of blasphemy against Islam on Tuesday, sentencing him to two years in prison in a case widely seen as a test of religious tolerance and free speech.

The governor, Basuki Tjahaja Purnama, was defeated last month by Anies Baswedan, a former minister of education and culture, in an election in which the blasphemy case, and religion, was a major issue.

Mr. Basuki began his sentence on Tuesday. Deputy Governor Djarot Saiful Hidayat is to serve as acting governor until October, when Mr. Anies takes office.

Blasphemy is a crime in Indonesia, a secular democracy with the world’s largest Muslim population. The sentence was harsher than what prosecutors had asked for; they had recommended two years’ probation on a lesser charge, which would have spared Mr. Basuki prison time.