Explosions and gunfire rang out as the Taliban attacked Kabul airport on Thursday in the militants' latest attempt to steal the initiative with the country in the grip of a presidential power struggle.
The overnight attack on an airport outbuilding, which ended after four assailants were killed by security forces or blew themselves up, came ahead of an audit of ballot papers from last month's presidential run-off election.
Some 23,000 ballot boxes are being transported by the Afghan army and NATO forces to the capital, where they will be examined at 100 verification stations in a process designed to resolve a political crisis that has threatened to widen Afghanistan's dangerous ethnic fissures.
NATO's International Security Assistance Force (ISAF) -- whose main Kabul compound lies next to the civilian airport -- is providing air transport for some 40 percent of the votes as it winds down its deployment after more than a decade of war.
The interior ministry said a group of insurgents seized a building under construction at the airport at around 4:30 am (0000 GMT) before opening fire with automatic weapons and rocket-propelled grenades.
The attack ended more than four hours later with all of the insurgents dead, the authorities said, with one security official wounded in the fighting.
Gul Agha Hashimi, a senior police official, said: "The attack is over, and the area is cleared from the insurgents. All the insurgents who were holed up in an under-construction building were killed."
Mohammad Ayub Salangi, the deputy interior minister for security, said on Twitter that four insurgents had been involved.
"The last insurgent has just blown himself up, because he knew the ANSF (Afghan National Security Forces) were on the way to capture him," he said.
A separate police statement said one Afghan soldier was wounded in the assault but there were no reports of civilian casualties.
Civilian flights from the airport north of Kabul meanwhile were suspended.
ISAF and Afghan military helicopters were seen hovering over the area during the attack, which came after a devastating suicide bombing at a busy market in southeastern Paktika province on Tuesday that killed at least 42 people.
Taliban militants claimed responsibility for Thursday's attack.
"A number of our mujahedeen armed with heavy and light weapons have launched an attack on Kabul International Airport," the insurgents' spokesman Zabiuhallah Mujahid said in a statement.
The attack came as Afghanistan geared up for a massive poll audit agreed by the two rival presidential contenders, Abdullah Abdullah and Ashraf Ghani, following a deal brokered by US Secretary of State John Kerry.
Election officials expect that the results of the audit, which will take at least three weeks to complete, will be accepted by both candidates after weeks of bitter dispute over fraud claims.
The impasse over the vote to succeed President Hamid Karzai has raised fears of a return to the ethnic violence of the 1990s.
Abdullah -- who says he already suffered one stolen election at Karzai's hands in 2009 -- is half-Tajik while Ghani is from the majority Pashtun community, as are the Taliban.
Every one of the 8.1 million votes cast in the run-off election will be checked for signs of fraud in a painstaking process in Kabul.
The Kabul airport is a prime target for insurgents. Militants destroyed Karzai's parked helicopter and damaged three other choppers after firing rockets into the airport on July 3.