Mr. Aan’s troubles began in January 2012 when a mob in the Dharmasraya district of West Sumatra showed up looking for him at a government planning office where he worked as a data analyst.

“They wanted me to stop saying there is no God,” he said. “I told them that it was my right to express my beliefs.”

Police officers were called to prevent any violence, and they instead escorted Mr. Aan to the local police station, where he found himself being interrogated and, within hours, charged with disseminating information aimed at inciting religious hatred. The next day, he was charged with blasphemy and inciting others to embrace atheism.

A court in Padang, the capital of West Sumatra Province, threw out the blasphemy and atheism charges, but it convicted Mr. Aan in June 2012 of trying to incite religious hatred under the electronic information law and sentenced him to two and a half years in prison.

“What I posted was for discussion, not to incite hatred,” he said in the interview.

Mr. Aan’s case was among several controversial prosecutions over comments made on the Internet in Indonesia, where Twitter and Facebook are extremely popular.

A homemaker was jailed and charged with defamation in 2009 after complaining about what she said was an incorrect hospital diagnosis in a private email that found its way online. In February, a Twitter user was sentenced to a year’s probation for “libelous tweets” against a former national lawmaker who had been convicted and sent to prison for corruption.

“It’s funny — we say we have freedom of expression, but it’s only up to a certain point,” said Enda Nasution, an Indonesian blogger. “I think we are absorbing all of these new norms, and with the Internet, we are experimenting with what we can and can’t do. Atheism is a no-no, it seems.”