Taliban armed with suicide vests, guns and rockets stormed a heavily fortified airfield in Afghanistan where Prince Harry is deployed, killing two US Marines and attacking aircraft in a major security breach.
The militia, which is leading a 10-year insurgency against 117,000 NATO troops, said it carried out the assault to avenge a US-made film deemed insulting to Islam that has sparked deadly riots across the Middle East and North Africa.
The attack on Camp Bastion in southern Helmand province, one of the toughest battlegrounds of the war, started at 10:15 pm (1745 GMT) on Friday, said US Army Major Adam Wojack.
The base was cleared of enemy fighters on Saturday morning, he added.
Prince Harry was never in danger, officials confirmed. Although the Taliban have vowed to kill the third in line to the British throne, one of its spokesmen told AFP that the assault "had nothing to do with the prince".
General Sayed Malook, head of the Afghan army in the south, said a suicide bomber blew himself up, blasting a hole in the perimeter wall and allowing insurgents to storm inside with guns and rocket-propelled grenades.
"As soon as they entered the base, fighting started. Afghan forces were not involved, they only helped to extinguish the fire," Malook told AFP.
A fuel reservoir and an aircraft hangar were set alight and it took until dawn to extinguish the blaze, he said.
The US-led NATO forces said multiple aircraft and "structures" were damaged in the assault on the airfield, which is used by both American and British forces.
Eighteen insurgents were killed -- including the suicide bomber -- and another was wounded and captured, said Wojack. They were dressed in camouflage, he said, but declined to say whether they were Afghan army uniforms.
A defence official in Washington said two US Marines were killed. NATO's US-led International Security Assistance Force said some personnel were wounded, but gave no details in line with policy.
The British defence ministry described the attack, on the eastern side of the runway, as "significant" but a spokesman said the attackers got "nowhere near" the prince as he was in lockdown with other soldiers at the base.
The ministry reiterated that Harry's presence in Afghanistan was constantly being reviewed.
The brazen attack is likely to raise serious questions about how insurgents managed to penetrate such a massive logistics hub in the desert, which in June Britain said was home to 28,000 soldiers.
In March, an Afghan man died after trying to ram a truck into US Marines waiting on the tarmac to greet US Secretary of Defence Leon Panetta as he flew into Camp Bastion.
There are growing concerns about Afghan personnel opening fire on their NATO colleagues, and two more were killed in Helmand provincial capital Lashkar Gah on Saturday, bringing to 47 the number of Western soldiers killed in such attacks so far this year.
The attacker was killed in return fire, the military said, refusing to disclose the nationality of the victims, though a Pentagon official said the two dead were not believed to be US troops.
The assailant was believed to be a member of the controversial Afghan Local Police force, which US special forces stopped training this month in order to vet about 1,000 recruits.
A Taliban spokesman claimed Friday's Bastion attack was waged to avenge a low-budget American YouTube film, "Innocence of Muslims", which has incited a furious wave of deadly anti-American violence in Yemen, Libya and Sudan, and protests in many other countries.
"A number of mujahideen fighters have carried out suicide attacks on Camp Bastion in Helmand in revenge for the insulting movie by the Americans," spokesman Qari Yousuf Ahmadi told AFP by telephone.
But the Taliban this week also vowed to kill Prince Harry, who is deployed at the base as an Apache helicopter pilot, and who celebrates his 28th birthday on Saturday.
In 2008 Harry was hastily withdrawn from Afghanistan when a news blackout surrounding his deployment on the ground directing aircraft in attacks on Taliban positions, was broken.
This time, however, the government released images of him in Afghanistan from the start, saying that any risk "has been, and will continue to be, assessed".
The Taliban have stepped up attacks as NATO hands responsibility to Afghan forces and accelerates a phased withdrawal that will see most Western troops leave the country by the end of 2014.
Around 330 Western troops have been killed in Afghanistan so far this year, according to the iCasualties website, 253 of them American.