In Pakistan, the lynching of a journalism student by classmates over alleged blasphemy offenses has caused national soul-searching.

At the start of this year, Mashal Khan was a 23-year-old with his whole future ahead of him. He was known for having a liberal outlook, including relatively secular views on religion and society. Those views had already made him unpopular on the campus of the Abdul Wali Khan University, in the city of Mardan, where he studied journalism, according to other students the BBC interviewed.

On April 13, however, he was attacked by a mob of students alleging blasphemy against Islam. Smartphone recordings of the attack show a crowd of several hundred men entering his hostel, torturing him and beating him to death. One of Khan's friends was also attacked and nearly killed but managed to escape. University staff can also be seen in the footage of the mob, as well as student representatives of Pakistani political parties. Some staff say they tried to stop it.

Khan had reportedly described himself on his Facebook page as "The Humanist."

The attack take places in a polical climate in which blasphemy accusations are increasingly dangerous. Blasphemy is a capital crime in Pakistan, and although that punishment has never been officially carried out, those accused of blasphemy are frequently murdered before they can come to trial. Politicians and activists who have simply called for reform of the law have also been killed.

According to the BBC's Pakistan correspondent Secunder Kermani, Khan's case has reignited concern over the government's emphasis on blasphemy laws.

"In recent weeks the prime minister and the authorities have talked a lot about blasphemy. They've talked about banning all social media in order to stop blasphemous content. So there has been some [feeling] that the mood was set for this [crime]."

Prominent politician Imran Khan visited the victim's home and Nobel Prize laureate Malala Yousafzai publicly condemned the attack. “We have forgotten our religion, values and dignity,” she reportedly said.

An investigation has led to the arrest of several suspects.

Confession of one of those arrested in Mashal Khan case: says he has long accused Mashal of being blasphemous and anti Islamic 1/2 https://t.co/TEqoblyxrK — Secunder Kermani (@SecKermani) April 17, 2017

Kermani says there is limited optimism that Khan's killers will face justice.

"At the moment there's a huge amount of public opinion demanding that action be taken. And that feeling comes from across the political spectrum," Kermani says. "Having said that, the justice system in Pakistan is ridden with problems. People who have the right connections are often able to escape punishment."