
The blast tore through the mosque's outer wall, crushing the adjacent police office and killing 15 officers.
Two armed men tried to breach the police compound, exchanging fire with security forces; one was killed and the other escaped.
The attack follows a roadside bomb in Hangu that killed six soldiers, prompting a raid that killed 10 suspected Taliban members.
The Pakistani Taliban, linked to the Afghan Taliban, have escalated attacks on police and civilians, including a 2023 Peshawar mosque bombing that killed 101.
Prime Minister Shehbaz Sharif condemned the attack, while President Arif Alvi offered prayers for the wounded; many injured worshippers remain in critical condition.
Security forces have launched a probe, and the government will convene a cabinet meeting to discuss heightened security measures.