KABUL, Afghanistan -- 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 U.S. Secretary of Defense James Mattis.

In response, the U.S. said it launched an airstrike that mistakenly caused an undisclosed number of civilian casualties.

An 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 gunbattle, officials said.

Get Breaking News Delivered to Your Inbox

Later, the U.S. military issued a statement saying that it had responded with an airstrike.

"Tragically, one of the missiles malfunctioned, causing several casualties," the U.S. command said. It expressed regret for having harmed civilians but did not say whether any of the casualties were killed.

"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 added. The statement said the original Taliban attackers had fired several rounds of "high-explosive ammunition, including mortars, in the vicinity of" the Kabul airport.

Zabihullah Mujahid, a Taliban spokesman, claimed responsibility for the attack on his official Twitter account. The Islamic State of Syria and Iraq (ISIS) also claimed responsibility for the attack.

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

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

The attack -- both its location, the Kabul airport, and the purported target, a visiting U.S. 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 gunbattle 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 U.S. Defense Secretary Mattis" and that "losses (were) caused" in the attack.

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

Speaking to The Associated Press later Wednesday, Stoltenberg denounced that attack as a "terrorist act" that shows the militants' "weakness."

Tumor Shah Hamedi, director of Kabul airport, said all flights were halted as a result of the attack.

At the presser, both Mattis and Stoltenberg pledged continued support for Afghanistan and vowed to do everything possible so the country "doesn't again become a safe haven for international terrorists."

Stoltenberg said NATO is aware of "the cost of staying in Afghanistan, but the cost of leaving would be even higher."

"If NATO forces leave too soon, there is a risk that Afghanistan may return to a state of chaos and once again become a safe haven for international terrorism," he said.

Stoltenberg also said NATO was committed to funding the Afghan security forces until at least 2020, and would continue to provide them almost a $1 billion each year.

Ghani said the Taliban can choose either to align with international terrorism or renounce violence and join a peace process with the government.

Mattis said Washington supports a negotiated settlement between the Taliban and Afghanistan. "The sooner the Taliban recognize they cannot win with bombs, the sooner the killing will end," he said.

Last month, President Trump hinted he would embrace the Pentagon's proposal to boost troop numbers by nearly 4,000, augmenting the roughly 8,400 Americans now in Afghanistan. The combined U.S. and NATO troop contingent currently in the country is about 13,500.

The additional American forces would be deployed to expand training of the Afghan military and beef up U.S. counterterrorism operations against al-Qaida, a growing ISIS affiliate in Afghanistan, as well as the Taliban and other extremist groups.

In the interview with the AP, Stoltenberg said the "attack on the airport is a sign of weakness, not the sign of strength" and added that to "attack a civilian airport is a criminal act, it is terrorist act and it just shows the importance of fighting these kind of organizations in Afghanistan."

He stressed the importance of fighting extremists as the best way to ensure "they are not able to expand and to go beyond Afghanistan and launch new attacks against other countries, including NATO countries."

The fight against extremists is "going on in many places in Syria, in Iraq, but also in the streets in Europe, in United States and therefore, we have to stand together, we have to work together and we need to be prepared for the long haul, because this is not easy, this will take time", he added.

The U.S. Embassy in Kabul condemned the airport attack, saying it does "not diminish our and our partners' resolve to stand with the people of Afghanistan in their quest for a more prosperous, stable, and secure future,"

In other violence, hundreds of Taliban insurgents attacked a security post in Afghanistan's western Farah province, killing at least 10 policemen and threatening to overrun the position.

Hakim Noori, the governor of the Pusht Rod district, said almost 300 Taliban fighters took part in the attack, which began on Tuesday night. He said the insurgents mined the area around the base to prevent authorities from sending in reinforcements.

Farid Bakhtawar, the head of the provincial council, confirmed the killing of the policemen and warned they would be overrun if reinforcements do not arrive soon.