At least a dozen Afghan security forces were killed when a suicide attacker driving an explosives-packed Humvee blew himself up in the southern province of Kandahar.

The Taliban claimed responsibility for the deadly assault on the government and police headquarters in Maroof district that also wounded several others.

"Twelve security forces were killed, and four others were wounded," Kandahar police spokesman Zia Durrani said. Durrani said the Taliban attackers had been "defeated".

READ MORE: The Taliban - Undefeated and possibly undefeatable

A border police commander in Maroof, which borders Pakistan, gave a slightly higher toll, telling AFP news agency that 14 security personnel had been killed and eight wounded in the attack that happened late Wednesday.

"The intensity of the blast caused damage to the building and led to casualties," he said. "The clean-up operation is under way in the area."

Taliban spokesman Qari Yusouf Ahmadi said the Taliban captured Maroof for a few hours and after removing weapons and other items left the district.

The attack is the latest deadly assault by the Taliban, which now controls swaths of territory across the country.

During a high-profile visit by US Defence Secretary James Mattis and NATO chief Jens Stoltenberg to the Afghan capital Kabul on Wednesday, Afghan fighters launched a volley of rockets near the city's international airport.

A US air raid launched in support of Afghan security forces who confronted the attackers caused "several casualties" when a missile malfunctioned.

One person was killed and 11 others wounded in the assault that lasted several hours, according to the interior ministry.