Asia Bibi's acquittal and welcome abroad have given other detainees cause for hope. (File)

One prisoner is an illiterate Christian street cleaner who got into an argument with a Muslim friend while they were out drinking. Another is a US-trained university professor whose liberal Facebook posts upset Islamist student activists.

A third is a middle-aged woman who now occupies the cell vacated by Asia Bibi, the Pakistani field hand who was sentenced to death for blasphemy in 2010 and acquitted by the Pakistan Supreme Court twice. She was allowed to leave for Canada this month after spending nearly a decade on death row.

These three Pakistanis are among 40 imprisoned on blasphemy charges or convictions. About half are serving life terms and half have been sentenced to death. Pakistan has never executed anyone for blasphemy, but many convicts are held in solitary confinement for years while awaiting appeals.

Bibi's acquittal and welcome abroad have given other long-term detainees cause for hope, but their lawyers and family members say it is a very slim one. Accused blasphemers are reviled by the public, few lawyers are willing to represent them, and lower courts are pressured to convict. Appeals courts often commute death sentences to life terms, but only after years of tension, isolation and often declining health.

One convicted man, Wajihul Hasan, has been on death row since 2002. Just two weeks after Bibi was acquitted last November, two brothers in Lahore, Qaiser and Amoon Ayub, were sentenced to hang for making "derogatory remarks" about the prophet Muhammad on a Christian website.

"Now that Asia Bibi is free, I pray that God will help my husband too," said Sobia Masih, 30, the wife of Sawan Masih, the street cleaner in Lahore who was accused of insulting Islam in 2013 during a dispute. He was sentenced to death in 2014, and Sobia last saw him in prison at Christmas. "This has turned our lives upside down," she said. "I have to live in hiding, and my children do not tell anyone he is their father."

As with many blasphemy cases, the charges against Masih were widely reported to have ulterior motives. His family and neighbors said local industry owners wanted to seize the area to build steel mills. Nearby Muslims, enraged by rumors of Masih's offensive talk, attacked and burned the Christian neighborhood to the ground.

"I handed Sawan over to the police myself so the mob wouldn't kill him," said Joseph Francis, a Christian activist at a legal aid center in Lahore that assists blasphemy defendants.

Mob violence against accused blasphemers is common in Pakistan, though rarely prosecuted. This week, a Pakistani court upheld death sentences for three Muslims, but acquitted two others, in the 2014 mob killing of a Christian couple who were falsely accused of throwing Koran pages in the trash. They were beaten to death and thrown into an open-air brick furnace.

The ruling reflected growing judicial concern over religious violence at a time of increasing organized agitation against blasphemy, including death threats against Bibi. Confrontations have spread from poor minority communities to college campuses with hard line Islamist student groups.

In 2013, Fulbright scholar Junaid Hafeez had returned from studying at Jackson State College in Mississippi and was teaching English literature at a university in Multan city. An outspoken liberal, he was denounced by Islamist students for hosting feminist authors. They also accused him of posting offensive material on Facebook, including comments about the wives of the prophet Muhammad.

The police arrested him, searched his laptop and charged him with blasphemy. Hafeez has remained in solitary confinement since 2014, while efforts to defend him have been thwarted by threats and violence. His first lawyer quit after being hounded by conservative colleagues. His second lawyer, rights activist Rashid Rehman, was warned in court by prosecutors that he would not be alive for the next hearing on Junaid's case.

Several days later, Rehman was shot dead in his office by unknown gunmen.

Hafeez is now represented by Asad Jamal, who said that repeated court delays have prevented his case from coming to trial. He said Hafeez, now 33, was seen as a threat by various campus interests and framed for provocative online writings that were circulated or electronically altered by others.

"There was complex conspiracy against him," Jamal said. "Junaid raised questions on many social issues, but there is nothing blasphemous in anything he wrote or posted." After five years in prison, he said, the outgoing academic and poet has become "an agitated, angry person."

Many Muslim countries have laws against blasphemy, but Pakistan's are exceptionally harsh and easy to abuse. Any act intended to "outrage religious feelings" is punishable by 10 years in prison. Defiling the Koran mandates a life sentence, and "derogatory" comments against the prophet Muhammad require "mandatory death."

There is a special law for Ahmadis, a religious minority that claims to be Muslim but is widely ostracized and legally banned from proselytizing. Ahmadis are frequent targets of personally motivated blasphemy charges, and four are in prison under death sentences. But the mere accusation, Ahmadi leaders say, can be ruinous.

"Once you are blamed for blasphemy, your life is gone," said Saleem ud Din, a spokesman for the national Ahmadi Community organization. "No matter how unfounded the allegations, and even if the court acquits, you can't take chances because you can be killed."

Even though Muslims such as Hafeez can be charged with blasphemy, most defendants are members of religious minorities, often Christians from poor communities. Increasingly, cellphones and social media are playing a role, and police investigators go to enormous efforts to track blasphemous content on emails or texts.

The woman imprisoned in Bibi's old cell, Shagufta Masih, was convicted with her husband Shafqat of sending blasphemous texts to the owner of an Islamic bookstall in Lahore. The couple have limited educations and had worked for years as school custodians, but police said they traced offensive English-language texts to their cellphone SIM cards.

In 2014, a judge ruled they had both committed a "heinous offense" against Islam and sentenced both to hang.

Saif ul-Maluk, the lawyer who previously defended Bibi, now represents the couple. He said the charges against them were fabricated and that someone had used their SIM cards to malign them, possibly due to a personal dispute. He said Shagufta had told him that the police beat her husband and threatened to "parade her naked in public" if he did not confess.

"The whole story was false," he said.