Naseem was standing trial on charges of blasphemy. Photo: Shutterstock.

A man was shot dead in a courtroom in the middle of his trial for alleged blasphemy - with his body left slumped over seats as armed guards descended on the scene. Tahir Ahmad Naseem was shot six times during his hearing in the northwestern Pakistani city of Peshawar on Wednesday - with the rogue gunman quickly arrested. Naseem was accused of claiming to be a prophet by a teenager in 2018 and had been in prison awaiting trial ever since - with blasphemy legally punishable by death in the south Asian country. And while no-one is yet to have been given the death penalty for it, violent attacks against the accused have become commonplace.

Video footage shared on social media shows his body in the courtroom - while another clip shows the attacker in handcuffs. Naseem and his accuser, Awais Malik, a student at a madrassa - an Islamic religious school, had been speaking online before meeting in a shopping centre in Peshawar, reports the BBC.

READ ALSO: Man denies love affair with aunt shot dead at City Park

It is unclear how the gunman, named only as Khalid, was able to bring the weapon into the court. According to reports, Naseem had been raised in the Islam sect of Ahmadi before leaving and allegedly claiming he was a prophet, posting videos online calling himself a messiah. The BBC reports the community's leader suggested the accused had mental health problems. A police official told Al Jazeera: "The culprit accepts responsibility for killing him and says that he killed him for having committed blasphemy. (The suspect) has been arrested from the scene."

Naseem was accused of having violated sections 295-A, 295-B and 295-C of the Pakistani penal code, which deal with blasphemy against Islam, criminalising, among other things, "defiling the sacred name of the Holy Prophet Muhammad".

Since 1990, at least 77 people have been killed in connection with the accusation, according to an Al Jazeera tally.