The explosion occurred as worshippers had gathered in the Kucha Risaldar mosque in Peshawar’s old city area for Friday prayers.
Peshawar police chief Muhammed Ejaz Khan said the violence started when two armed attackers opened fire on police outside the mosque.
One assailant and one policeman were killed in the gunfight, and another policeman was wounded. The remaining attacker then entered the mosque and detonated a bomb.
Ambulances rushed through congested narrow streets and took the wounded to Lady Reading Hospital.
No group had immediately claimed responsibility.
More than 60 people were injured and the death toll may rise, said hospital spokesman Mohamed Asim.
More about: Pakistan