PESHAWAR, Pakistan — A young Pakistani Muslim walked into a courtroom in the northwestern city of Peshawar on Wednesday and shot and killed a fellow Muslim who was on trial for blasphemy, a police officer said.

It was not immediately clear how the assailant, identified as Khalid Khan, managed to get into the court amid tight security. The attacker was subsequently arrested.

The man on trial, Tahir Shamim Ahmad, had claimed he was Islam’s prophet and was arrested two years ago on blasphemy charges, according to Azmat Khan, the police officer. Ahmad died before he could be transported to hospital.

A rescue worker stands beside the body of Tahir Shamim Ahmad, who was accused of insulting Islam and was killed by a fellow Muslim, in an ambulance at a hospital in Peshawar, Pakistan, Wednesday, July 29, 2020. A young Pakistani Muslim man walked into a courtroom in the northwestern city of Peshawar and shot and killed Ahmad, who was on trial for blasphemy, a police officer said. (Credit: Muhammad Sajjad/AP.)

Blasphemy is an extremely controversial issue in Pakistan, where people convicted of the crime can be sentenced to life in prison or the death penalty. But crowds and individuals in Pakistan often take the law into their own hands.

While authorities have yet to carry out a death sentence for blasphemy, even the mere accusation can cause riots. Domestic and international human rights groups say blasphemy allegations have often been used to intimidate religious minorities and settle personal scores.

A Punjab governor was killed by his own guard in 2011 after he defended a Christian woman, Asia Bibi, who was accused of blasphemy. She was acquitted after spending eight years on death row in a case that drew international media attention. Faced with death threats from Islamic extremists upon her release, she flew to Canada to join her daughters last year.