Media playback is unsupported on your device Media caption Nato says Prince Harry was never in any danger despite the attack on Camp Bastion

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.

Analysis The Taliban say that the motive for the attack was the film that has outraged the Muslim world. But they also claim that they chose Bastion, at least in part, because the base is where Britain's Prince Harry is stationed as an Apache helicopter pilot. Nato insists Captain Wales, as the prince is known, was never in any danger, but there will be concerns about his security. However, there is no suggestion that his deployment will be curtailed. I have been told he was more than a kilometre away from the fighting. The bigger question is how were the Taliban able to penetrate a secure military base. The UK's Ministry of Defence concedes this was a significant attack but the bottom line is that the insurgents should never have got so far.

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.

Media playback is unsupported on your device Media caption Brigadier General Gunter Katz, ISAF, said they were looking at how the Taliban managed to attack the base

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.

What is Camp Bastion? Major transit centre with a large airfield, accommodates 28,000 mostly British personnel

Set up in 2006, now covers an area of about eight square miles

A logistical support centre for frontline troops, it also has a substantial field hospital

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".

Protest timeline - main flashpoints 11 September US embassy in Cairo attacked, flag torn down and replaced with black Islamist banner Mob attacks US consulate in Benghazi, US ambassador Chris Stevens and three other Americans killed 13 September Protesters break into the US embassy compound in Sanaa, Yemen, amid clashes with security forces 14 September Sudanese protesters attack US, German and UK embassies in Khartoum and clash with police. Three killed One person killed in Lebanon in protest at a KFC restaurant Protesters in Tunis attack the US embassy, with a large fire reported and shots heard. Two killed Riot police in Cairo clash with protesters near US embassy. One person killed In pictures: Anti-Islam film protests Press gloomy on West's ties with Muslim world

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.