KABUL, Afghanistan — The Taliban killed a senior Afghan election official on Wednesday and then boasted about it on Twitter, in what officials said was the first attack by the insurgents on an official of the Independent Election Commission in recent years.

The deputy police chief in Kunduz Province, Ebadullah Talwar, said that two men riding on a motorcycle opened fire on Mohammad Amanullah, the head of the Kunduz office of the commission, at 8:45 a.m., and that he died at a hospital.

Within an hour, Zabiullah Mujahid, a spokesman for the Taliban, was on Twitter to claim the attack.

“At 9 a.m. this morning, Engineer Mohammad Aman head of Kunduz Independent Election Commission was killed by our Mujahedeen in Takharistan area of Kunduz city,” the Taliban tweet read, using a shortened version of the victim’s name. It was apparently the first time the Taliban had used Twitter to officially claim responsibility for an assassination.

A spokesman for the commission in Kabul confirmed the killing but said that, despite the Taliban claim, it was too early to conclude who was behind Mr. Amanullah’s killing.