He struck shortly after Friday prayers had ended, witnesses said.
Hangu district police chief Mian Mohammad Saeed confirmed the attack was carried out by a suicide bomber.
He had earlier said that a bomb had been planted near the mosque.
No group claimed responsibility for the attack.
Hangu, which has a sizeable Shia population, has witnessed several sectarian attacks in the past few years.
Security forces cordoned off the area as rescue teams took the injured and bodies to nearby hospitals.
Eight persons with serious injuries were transferred to the provincial capital of Peshawar, state-run PTV reported.
The attack created tension in Hangu, which is located adjacent to the lawless tribal belt where several militant groups, including the Taliban, are active.