Prince Harry at Camp Bastion during Taliban attack
Prince Harry was at Camp Bastion in Afghanistan during an assault by the Taliban which killed two US marines.
American officials said small arms, rockets and mortars were used to attack the perimeter of the British base, home to troops from several countries.
The Taliban said it was a response to an amateur US-made film mocking Islam and later claimed the base was chosen because Harry was there.
Nato told Reuters news agency that the prince "was never in any danger".
Prince Harry, who is marking his 28th birthday, is in Afghanistan for four months on his second tour of duty.
The attack came as two Nato soldiers were killed by a man - thought to be a member of the Afghan local police force - who opened fire on troops in the south of the country. The gunman was subsequently shot dead.
The nationalities of the dead soldiers have not been made public.
On Friday, a British soldier - from 1st Battalion Grenadier Guards - was killed after his vehicle hit a roadside bomb in the Nahr-e Saraj district of Helmand province.
Camp Bastion is situated in the middle of the desert with excellent visibility all around, says the BBC's Jonathan Beale in Kabul.
The base includes personnel from the Denmark, Estonia and Afghanistan, as well as the UK and US. No UK casualties have been reported.
It is extremely heavily fortified and questions will be asked about how militants were able to stage the surprise assault, our correspondent added.
The attack comes a few days after Defence Secretary Philip Hammond visited troops there.
Sayed Malook, a commander in the Afghan National Army said the evening attack, which involved up to 20 Taliban fighters and lasted four hours, began with a suicide bomb blast that breached the base wall.
An International Security Assistance Force spokesman said that 18 Taliban fighters had been killed and one captured.
Describing the attack as "significant", an MoD spokesman said it was "there has been some damage to equipment which is still being assessed" and a "clearance operation" was taking place.
He added: "After swift action by ISAF forces, including UK personnel, the incident was contained."
In a telephone conversation with the BBC, Taliban spokesman Qari Yousuf Ahmadion reiterated earlier comments and said the attack was planned after they found out about the film US but added that Camp Bastion was chosen as the target because Prince Harry was there.
Isaf spokesman Brigadier General Gunter Katz said the Taliban was "claiming a lot... They lose any credibility and it's very hard to understand what's behind the motives of those claims."
Violent protests against Western embassies have swept the Muslim world amid widespread anger over the film called Innocence of Muslims. They began on Tuesday in Egypt. On Friday, at least seven people died in escalating unrest in Khartoum, Tunis and Cairo.
There are fears of a surge in violence ahead of the withdrawal of foreign forces from Afghanistan by 2014.
'Threats to kill'
Camp Bastion is one of the world's busiest airports because of the heavy helicopter and plane traffic.
But successful head-on attacks by insurgents that penetrate the perimeter fence, which is protected by hi-tech detection systems, are rare.
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.
Ahmad Majidyar, of the American Enterprise Institute think tank, told the BBC that Camp Bastion was a more likely target while the prince was there.
"One of the motivations could be the presence of Prince Harry in that camp, because the Taliban some days ago warned that they would target and kill Prince Harry," he said.
Prince Harry is the first member of the Royal Family to see active combat since his uncle Prince Andrew fought in the Falklands War.
Captain Wales, as the prince is known in the military, arrived as part of the 100-strong 662 Squadron, 3 Regiment, Army Air Corps earlier this month.
His first stint between 2007 and 2008 was cut short after 10 weeks because his presence was leaked by the international media.
For this current deployment, the Ministry of Defence made it clear it was willing to confirm Harry's role as he will be commanding an Apache helicopter and the threat to him is regarded as "low".
British forces have lost none of their 67 Apaches, although there have been two minor crashes.
During his previous deployment, Harry was a forward air controller directing planes bombing Taliban positions in Helmand.