The Taliban unleashed a barrage of rockets at the Kabul international airport on Wednesday in a brazen attack that the insurgents said targeted the plane of visiting US Secretary of Defense Jim Mattis.

In response, the US said it launched two missiles, one of which missed its intended target and killed at least one Afghan civilian.

Afghan officials said one Afghan woman was killed and 11 civilians were wounded in the Taliban attack. Afghan special forces managed to repel the attackers, killing four in an ensuing gun battle, officials said.

Later, the US military issued a statement saying that it had responded with an air strike.

"Tragically, one of the missiles malfunctioned, causing several casualties," the US command said.

Navy Captain William Salvin, spokesman for the US-led military coalition, said in a telephone interview that the US fired two Hellfire missiles. One struck its intended target, a building from which the insurgents had launched their mortar attack. The other one was programmed to hit the same target but went astray for unknown reasons, Mr Salvin said.

At least one Afghan civilian was killed by the malfunctioning Hellfire and an undetermined number of other civilians were wounded, Mr Salvin said.

In its written statement, the US-led coalition expressed regret for the civilian casualties.

"We take every precaution to avoid civilian casualties, even as the enemies of Afghanistan continue to operate in locations that deliberately put civilians at very high risk," it said. The statement said the original Taliban attackers had fired several rounds of high-explosive ammunition, including mortars, in the vicinity of the Kabul airport.

The US statement said the insurgents also detonated suicide vests, "endangering a great number of civilians".

Mr Mattis was meeting with Afghan President Ashraf Ghani at the time of the attack, along with visiting Nato Secretary-General Jens Stoltenberg. Mr Mattis' plane was not hit.

The attack — both its location, the Kabul airport, and the purported target, a visiting US official's plane — underscored the ability of the insurgents to still stage high-profile attacks despite Afghan security forces' struggle to stem Taliban gains.

Najib Danish, spokesman for the Interior Ministry, said the Taliban fired up to about six projectiles at and near the airport, hitting both the international and the military sector of the sprawling hub and also two civilian houses nearby. The gun battle with Afghan special forces left "four of the terrorists dead," he said.

Taliban spokesman Zabihullah Mujahid said in a tweet that the "military section of the Kabul airport was hit with missiles; target was plane of US Defence Secretary Mattis" and that "losses (were) caused" in the attack.

Mr Ghani said during a joint press conference with Mr Mattis and Mr Stoltenberg that Afghan special forces troops quickly brought the assault under control. Mr Mattis called the attack "a crime" during the news conference, which was broadcast live.