A suicide bomber has detonated his explosives outside a Shia mosque in northwestern Pakistan as worshippers were leaving Friday prayers, killing 22 people and wounding over 30 in the latest apparent sectarian attack in the country, police said.

Shia Muslims in Pakistan have increasingly been targeted by militant Sunnis who consider them heretics, and 2012 was the bloodiest year for the minority sect in the country's history.

The attack on the mosque took place in the town of Hangu in Khyber Pakhtunkhwa province, which has experienced previous clashes between the Sunni and Shia communities that live there.

The bomber staged his attack at one of the mosque's exits leading to a bazaar, said Hangu police chief Mian Mohammad Saeed.

The blast damaged several small shops and peppered a wall with shrapnel, leaving scores of pockmarks, according to local TV footage. Ambulances rushed in to pick up the dead and wounded, as police tried to keep back onlookers in the crowded bazaar.

The explosion killed 22 and wounded over 30 people, said another police officer, Naeem Khan. One policeman who was guarding the mosque was killed and another was injured. Most of the dead and wounded were Shias, but some of the casualties were also from the country's majority sect since there is a Sunni mosque nearby, said Khan.

Targeted attacks

No group has claimed responsibility for the attacks, but suspicion will likely fall on the Pakistani Taliban or Lashkar-e-Jhangvi, which have both carried out bombings against Shias.

The worst sectarian violence in Pakistan in recent years has been in southwestern Baluchistan province, which has the largest concentration of Shias in the country. A twin bombing last month at a billiards hall in the provincial capital, Quetta, killed 86 people, most of them Shias.

According to Human Rights Watch, more than 400 Shias were killed in targeted attacks in Pakistan in 2012, including over 120 in Baluchistan.

Sectarian militant groups, such as Lashkar-e-Jhangvi, have increased their strength through alliances with al-Qaida and the Pakistani Taliban, which has been waging an insurgency against the government for the past several years.

Rights organizations have criticized the Pakistani government for not doing enough to crack down on the attacks against Shias.

Pakistan's intelligence agencies helped nurture Sunni militant groups like Lashkar-e-Jhangvi in the 1980s, to counter a perceived threat from neighboring Iran, which is mostly Shiite. Pakistan banned Lashkar-e-Jhangvi in 2001, but the group continues to operate fairly freely.