PESHAWAR, Pakistan— A suicide bomber killed four other people and injured at least 33 after rushing into a crowded courtroom in the northwest Pakistan city of Peshawar on Monday and detonating his explosives, police and witnesses said.

The attack occurred at a time when Peshawar’s main courthouse, a heavily guarded compound in one of the country’s most violence-ridden cities, was bustling with lawyers and litigants attending morning hearings.

Police said there were two attackers, both wearing suicide explosives vests and armed with handguns. One of the gunmen was shot and killed by police before entering the grounds, police said.

The other was able to get past the outer cordon of police and enter the courthouse building. He detonated his explosives inside the courtroom of Kalsoom Azam, a female judge. Azam had just stepped out before the bomber burst into the room, police said. It was unclear whether she was the target.

Three civilians and a police officer were killed in the attack, police said.

Television footage showed rescue workers frantically carrying injured people down the courthouse steps, while other dazed and bloodied victims staggered out of the compound as ambulances drove up.

Peshawar’s central jail is located next to the courthouse, and Khyber-Pakhtunkhwa province Information Minister Iftikhar Hussain suggested it was possible that the attackers may have wanted to free militant prisoners housed there. No group had claimed responsibility for the attack as of Monday evening.

Militant attacks in Pakistan’s volatile northwest have continued despite signs from the federal government and the Pakistani Taliban that each is interested in peace talks. [Updated 7:35 a.m. March 18: However, a spokesman for the Pakistani Taliban announced Monday that the militant group has withdrawn its offer for peace talks, saying the government did not appear serious in wanting to follow through with negotiations.]

The Pakistani Taliban is the country’s homegrown insurgency that is responsible for waves of suicide bombings and other terror acts that have killed legions of Pakistanis in recent years.

Peshawar, northwest Pakistan’s largest city, has been the target of many of those attacks. In December, militants launched a coordinated assault on the city’s airport, killing at least five people and injuring 45 others. A week later, a suicide bomb blast killed a top provincial official and an outspoken opponent of the Taliban, Bashir Ahmad Bilour, as he was attending a political meeting in Peshawar.