Insurgents have attacked Nato’s heavily fortified Camp Bastion base in southern Afghanistan.
At least two US marines died when militants breached the perimeter of the sprawling base in Helmand province.
The Taliban told the BBC that they carried out the attack in revenge for a film mocking Islam which has triggered protests around the Muslim world.
Aircraft and buildings were damaged and Nato says a “clearance” operation is under way.
Camp Bastion is situated in the middle of the desert with excellent visibility all around, says the BBC’s Jonathan Beale in Kabul.
It is extremely heavily fortified and serious questions will be asked about how militants were able to stage the brazen surprise assault.
The UK’s Prince Harry began a second tour of duty at the base just over a week ago, but is said to be unharmed.
At least seven people died in protests over the film mocking the Prophet Muhammad in Khartoum, Tunis and Cairo on Friday and there are fears of further unrest.
‘Engulfed in fire’
Nato officials say insurgents used small arms, rockets and mortars in the attack on Camp Bastion.
The attack took place at about 22:00 on Friday (17:30 GMT), under cover of darkness.
The camp is home to troops from several countries and Friday’s attack hit the US compound, Camp Leatherneck.
Two US marines died, and Helmand’s governor said at least 16 Taliban fighters were also killed. Several other international troops were wounded.
Taliban spokesman Qari Yousef Ahmadi told the BBC that the target was US and UK soldiers.
In a later statement the Taliban said “tens” of fighters had been involved. It said the base was “engulfed in fire and covered in heavy smoke while the operation is still ongoing”.
It threatened “further retaliation throughout the country” for the “insult towards the beloved Prophet of Islam” carried in the film.
But the UK’s defence ministry said the incident had been “contained with a number of insurgents killed as a result”.
It said that a “clearance operation is being conducted and we are in the process of accounting for our people”.
Our correspondent says that suggests the fighting is over and Nato forces will be making sure no Taliban are hiding and all Nato personnel are present.
Camp Bastion has a high level of security and is one of the world’s busiest airports because of the heavy helicopter and plane traffic.
Earlier this year, a member of Nato forces was injured when an Afghan man drove a pick-up truck onto the runway, which then burst into flames, during a visit by US defence secretary Leon Panetta.
But successful head-on attacks by insurgents that penetrate the perimeter fence, which is protected by hi-tech detection systems, are rare.
Nato told Reuters news agency that Prince Harry was on the base at the time of the attack but was “never in any danger”.
The Taliban have previously threatened to target Prince Harry during his stay at Camp Bastion.
Their statement after the attack specifically referred to his presence there.
There are fears of a surge in violence in Afghanistan ahead of the withdrawal of most foreign forces by 2014.