At Mashal Khan's funeral, the imam at the local mosque refused to read the last rites, according to Swabi resident Salman Ahmed. A technician who was asked to do so in the cleric's place was confronted by several people afterwards.
Mashal has since been buried, but his ransacked university hostel room still has posters of Karl Marx and Che Guevara still hanging on the walls, along with scribbled quotes including one that reads: “Be curious, crazy and mad.”
The day before his death, a heated debate over religion with fellow students broke out at the dorm and led to people accusing Mashal of blasphemy against Islam. That attracted a crowd that grew to several hundred people, according to witnesses.
The mob kicked in the door, dragged Mashal from his room and beat him to death, witnesses and police said.
Mashal's death is the latest violence linked to accusations of blasphemy in Pakistan.
Those who knew Mashal described him as an intellectually curious student who openly professed devotion to Islam but asked many questions.
“Whatever he had to say, he would say it openly, but he didn't understand the environment he was living in,” said one of Mashal's teachers at Abdul Wali Khan University, who declined to be named for fear of retribution.
Aziz ur Rehman, a caretaker at the hostel who witnessed Mashal's debate with his fellow students, said he brought up arcane subjects.
Crimes related to blasphemy are a serious offence in the country and penalties range from small fines to the death sentence.
At least 65 people have been murdered over blasphemy allegations since 1990, according to figures from a Center for Research and Security Studies report and local media, and dozens more convicted of the crime are currently on death row in local jails.
In March, Prime Minister Nawaz Sharif issued an order for the removal of blasphemous content online, and said anyone who posted such content should face “strict punishment under the law”.
Police say they have arrested 20 suspects involved in Mashal's murder and have found no evidence to substantiate blasphemy allegations.
Rehman, the caretaker, said Mashal was alive when the police arrived, but that they did not approach the hostel until it was too late.
“They could have easily saved his life but they stood away from the mob ... I heard one officer say it's good that they sent this non-believer to hell,” he said.
Mardan police chief Mohammad Alam Shinwari denied the allegation that officers did not do enough to save Mashal.
“When we entered the campus, he had already been killed and the mob was trying to burn his body,” he said.
In Mashal's home town of Swabi, around 60km south of Mardan, his father, Iqbal Shaer, said the accusations of blasphemy were unfounded. “First they killed my son and now they are adding salt to our wounds,” he told Reuters.
Shaer, who runs a small business selling biscuits and chocolates to local retailers, said he had always been a lover of poetry and literature and encouraged his children to express themselves and appreciate the arts.
He added: “My wife told me this morning that she spent her life taking care of her son, but those who killed him have wasted that long struggle.”