PESHAWAR, Pakistan — Heavily armed militants killed at least 19 people and wounded more than 40 after they stormed into a Shiite mosque during Friday Prayer in a suburb of Peshawar, the main city in northwestern Pakistan, doctors and officials said.
The assault was the most fearsome show of violence in the Peshawar area since a Taliban attack on a school in December that killed about 150 people, and it offered a chilling reminder of the continuing threat from militants in Pakistan despite a concerted crackdown by the security forces.
The police said that at least four gunmen wearing vests rigged with explosives and lobbing grenades entered the crowded Imamia Mosque in Hayatabad, an upscale suburb that is adjacent to the Khyber tribal district, a notorious militant sanctuary.
Security guards at the mosque shot and killed one attacker, but three others made it into the main hall. They fired guns and flung grenades into a crowd of worshipers before detonating their vests, the provincial police chief, Nasir Khan Durrani, told reporters at the scene.
Policemen surveyed the scene after Taliban suicide bombers attacked a Shiite mosque in Peshawar, Pakistan, while victims were rushed to the hospital.
The number of casualties would have been higher if several grenades had not failed to explode, Mr. Durrani said.
A United Nations employee was among the dead. In a statement, the United Nations coordinator in Pakistan, Timo Pakkala, condemned the attack, saying, “Any violent act targeting minorities is totally unacceptable.” He also called on the government to foster tolerance in the country as it fights Islamist militancy.
Some witnesses said the attackers were wearing black police uniforms. Outside the mosque stood the charred remains of a vehicle they had used to reach the area and had set on fire moments before the assault.
The Pakistani Taliban claimed responsibility for the attack through a spokesman who said it was in revenge for the execution of a convicted militant known as Dr. Usman, who was hanged on Dec. 19. “This is a continuation of blood for blood,” he said in a statement emailed to journalists. “The government should expect further, and stronger, reaction.”
In a video sent from the same email address, a Taliban commander identified as Omar Mansoor, who also claimed responsibility for the Peshawar school attack in December, issued further warnings to the government. “Either Pakistan will become your graveyard, or God’s law, Shariah, will be implemented,” he said.
Government officials have blamed a Taliban-affiliated group for a suicide bomb attack on Jan. 30 at a Shiite mosque in Shikarpur, in the southern province of Sindh, that killed 61 people.
That attack was Pakistan’s deadliest sectarian assault since February 2013, when a bombing at a market in Quetta, the capital of the western province of Baluchistan, killed 89 people.
But government officials at the scene of Friday’s attack described it as a likely response to continuing Pakistani military operations in the nearby tribal belt, which have been stepped up since the assault at the Peshawar school in December.
Pakistan’s Parliament has also empowered the army to start trying Taliban suspects in military courts.
The government lifted a moratorium on executions in the wake of the Peshawar attack and on Friday hanged two convicted prisoners, bringing the number of executions since mid-December to 24.
Unlike those executed earlier, the two men hanged on Friday had not been convicted under Pakistan’s terrorism laws, a fact that Amnesty International criticized as a dangerous escalation by the country’s authorities.
“The death penalty is always a human rights violation, but the serious fair trial concerns in Pakistan make its use even more troubling,” the group said in a statement.
On Thursday, Pakistan’s military spokesman told reporters that the security forces had arrested 12 militants linked to the school attack but that six others, including the Taliban leader Maulana Fazlullah, remained at large.
Pakistani officials have said they believe Mr. Fazlullah is hiding in the mountains of eastern Afghanistan, but they have credited Afghan officials with helping pursue him, in a sign of thawing relations between the two countries.
Declan Walsh contributed reporting from London.