A suicide bomber has killed 19 mostly Sunni Muslims and wounded 45 in a crowded market outside a mosque in Pakistan's northwestern town of Hangu.

Hangu, part of Pakistan's border region with Afghanistan, has been racked by sectarian violence between Sunni and Shia tribes.

It is just a few kilometres from Parachinar, which has a significant Shia population against whom hardline Sunni militant groups have launched attacks for years.

A senior police officer Imtiaz Shah said most of the dead had been coming out of the mosque after Friday prayers when the blast hit.

No group has claimed responsibility so far.