PESHAWAR, Pakistan — An explosion in a market in northwestern Pakistan on Friday killed at least 21 people and wounded 33 in what the police described as a suicide bombing.

The Pakistani Taliban claimed responsibility for the attack in Hangu, about 70 miles west of Peshawar, the capital of Khyber-Pakhtunkhwa Province. Abu Omar, a Taliban commander in the neighboring tribal region of North Waziristan, said in a telephone interview that the attack was in revenge for the killing on Thursday of a Sunni cleric.

The cleric, Mufti Abdul Majeed Deenpuri, 60, was shot in the southern port city of Karachi, setting off fears of reprisals against Shiites.

Mr. Deenpuri was a senior teacher at Jamia Binoria, one of the largest seminaries in Pakistan. A gunman opened fire on a vehicle carrying the cleric and a colleague at a busy intersection and then fled.