Insurgents have attacked Nato's heavily fortified Camp Bastion base in southern Afghanistan, officials say.
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.
In a separate development, two British soldiers were shot dead in Helmand by a man wearing an Afghan police uniform.
The Ministry of Defence in London said the attacker opened fire at a checkpoint in the Nahr-e Saraj district. Officials have not released the names of the soldiers but say that they were from 3rd Battalion The Yorkshire Regiment and their families have been told.
The incident means 47 Isaf members have died this year at the hands of Afghan military or police personnel, or by insurgents posing as them.
Another British soldier was also killed when his vehicle hit a roadside bomb in the Nahr-e Saraj district.
'Engulfed in fire'
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 coalition forces are investigating how militants were able to stage the brazen surprise assault.
Aircraft and buildings were damaged but Nato said its forces killed 18 of the insurgents and captured one.
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.
The attack came after at least seven people died in protests over the film mocking the Prophet Muhammad in Khartoum, Tunis and Cairo on Friday and amid fears of further unrest.
Nato officials say insurgents used small arms, rockets and mortars in the attack on Camp Bastion which took place at about 22:00 on Friday (17:30 GMT), under cover of darkness.
Major Adam Wojack, from Isaf joint command in Afghanistan, said the attackers found a "vulnerable part of the perimeter" and quietly breached it.
Once inside, the insurgents attacked the airfield side of the compound and caused "some damage to aircraft, damage to structures and killed those two marines", the officer said.
The attack was finally fought off by mainly American and British personnel who "ended up killing 18 of those attackers", he said.
Isaf said one of the attackers was also wounded and subsequently captured during the assault.
The camp is home to troops from several countries and the assault hit the adjoining US compound, Camp Leatherneck.
In addition to those killed, several other international troops were wounded in the raid.
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".
It threatened "further retaliation throughout the country" for the "insult towards the beloved Prophet of Islam" carried in the film.
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.