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.