ISLAMABAD, Pakistan — A prominent anti-Taliban politician in northwestern Pakistan was killed on Saturday in a suicide bombing, underscoring the dangers faced by politicians who stand up to the insurgents.

Police officials said the bomber detonated explosives near a filling station while a vehicle carrying the politician, Fateh Khan, passed by in a town in the Buner district, in the restive Khyber-Pakhtunkhwa Province. Two security guards working for Mr. Khan and three passers-by were also killed in the attack, seen as an act of retribution by the Taliban.

Ehsanullah Ehsan, a Taliban spokesman, claimed responsibility for the attack and warned of more assassinations. “Our mujahedeen killed him,” he said in a telephone interview. “We carried out this noble deed.”

Mr. Khan had long been a member of the Awami National Party, a secular party that rules the province and opposes the Taliban insurgency. About three years ago, Mr. Khan shifted political loyalties and joined forces with an opposition politician, Aftab Ahmed Khan Sherpao, a former interior minister. Mr. Khan also led an anti-Taliban militia in the province.