The attack in Logar province outside the capital, Kabul, was the latest to target Afghan security forces following the withdrawal of most foreign combat troops at the end of last year.

In neighbouring Pakistan, another Taliban suicide attack on a provincial police headquarters killed at least seven people in the eastern city of Lahore, in what militants called a revenge bid for the recent hangings of their colleagues.

The Afghan and Pakistani Taliban are separate groups that share the goal of establishing hard-line Islamic rule.

In the Afghan assault, the four attackers rushed the gates of the police compound in early afternoon, with one detonating his explosives-filled vest at the main gate and killing one policeman, Logar government spokesman Din Mohammad Darwish said.

The attack triggered a 25-minute battle with police, he said.

Another of the militants reached the station's dining hall, killing 21 police and wounding seven when he detonated his vest, said Abdul Wali Toofan, Logar's deputy police chief. The other two attackers were killed with no further casualties.

Zabihullah Mujahid, a spokesman for the Taliban, claimed responsibility on his official Twitter feed.

Earlier on Tuesday, a bomb attached to a vehicle wounded one person in Kabul, police said, breaking a recent lull in attacks in the Afghan capital.

Kabul had been rocked by a string of bombings by insurgents late last year in the run-up to the withdrawal of most foreign combat troops from Afghanistan after 13 years of war.

A suspected magnetic bomb attached to a 4-wheel-drive vehicle exploded in the east of the city, Kabul police chief Abdul Rahman Rahimi said.