Pakistan's Supreme Court acquitted a man Wednesday who was sentenced to death for blasphemy in 2002, saying there was a lack of evidence against him.

Wajih-ul-Hassan was exonerated Sept. 25, with the court deciding that prosecutors hadn't proven that letters which were the basis of the accusation had in fact been written by him.

Pakistan's state religion is Islam, and around 97 percent of the population is Muslim. The country's blasphemy laws impose strict punishment on those who desecrate the Quran or who defame or insult Muhammad. Although the government has never executed a person under the blasphemy laws, accusations alone have inspired mob and vigilante violence.

The allegations against Hassan arose from letters he allegedly wrote to a lawyer, according to Dawn, a Karachi-based daily.

The lawyer, Ismail Qureshi, had sought amendments to the Pakistan Penal Code, saying that blasphemy should be punished only by capital punishment; the PPC also allows life imprisonment as a sentence for the crime.

Hassan allegedly wrote letters to Qureshi in 1998 which the lawyer deemed blasphemous; Qureshi went to the police and filed a petition against Hassan the following year.

Mohammad Amjad Rafiq, additional prosecutor general of Punjab, told Dawn that in 2001 Hassan confessed before a manager at his place of work; the manager then took Hassan to a police station, where he was arrested.

The next week, a handwriting expert said that Hassan's writing matched the blasphemous letters.

Hassan was convicted and sentenced, a decision which was subsequently upheld by the Lahore High Court.

But the Supreme Court overturned Hassan's conviction this week, saying Hassan's "extra-judicial confession" and the testimony of the handwriting expert were not strong enough evidence of his guilt, and there were no witnesses to the supposed crime.

"Presumption of innocence remains throughout the case until such time the prosecution on the evidence satisfies the court beyond reasonable doubt that the accused is guilty of the offence alleged against him," the Supreme Court's decision reads.

"There cannot be a fair trial, which is itself the primary purpose of criminal jurisprudence, if the judges have not been able to clearly elucidate the rudimentary concept of the standard of proof that prosecution must meet in order to obtain a conviction," it continued.

Pakistan's blasphemy laws are reportedly used to settle scores or to persecute religious minorities; while non-Muslims constitute only 3 percent of the Pakistani population, 14 percent of blasphemy cases have been levied against them.

Many of those accused of blasphemy are murdered, and advocates of changing the law are also targeted by violence.

The blasphemy laws were introduced between 1980 and 1986. The National Commission for Justice and Peace said more than 1,300 people were accused under this law from 1987 until 2014. The Centre for Research and Security Studies reported that at least 65 people have been killed by vigilantes since 1990.

More than 40 people are serving a life sentence or face execution for blasphemy in the country.

(Story continues below)

Last year, the Supreme Court of Pakistan overturned the blasphemy conviction of Asia Bibi, a Catholic woman who was accused in 2009. Her initial conviction had also been upheld by the Lahore High Court.