A Taliban commander told Sky News that Harry was the main focus of the attack, but other media organisations reported it was in revenge for an anti-Islamic film.
The prince was unharmed, but two US Marines were killed and several more wounded in last night's attack.
A British soldier from 1st Battalion Grenadier Guards was killed by a roadside bomb in an unrelated incident yesterday. He died when his vehicle hit an improvised explosive device in the Nahr-e Saraj district of Helmand province. Next of kin have been told.
Harry, an Army captain, is based at Camp Bastion for his second tour of duty.
US officials said the attack was by heavily-armed insurgents and involved a range of weaponry, including mortars, rockets or rocket-propelled grenades, as well as small arms fire.
Harry was about two kilometres away with other crew members of the Apache attack helicopters, of which he is a co-pilot gunner, when the attack took place, sources said. There are no indications of any British fatalities or injuries.
A spokesman for the International Security Assistance Force coalition (Isaf) in Afghanistan said the attack happened near an airfield on the north-east side of the base, which houses American forces in Camp Leatherneck.
A Ministry of Defence source said: "After saying this attack was mounted in reaction to the video on Islam, it is entirely predictable that the Taliban have changed their tune to say it was aimed at Captain Wales.
"The insurgency who mounted this attack - most of who were killed by Isaf - were nowhere near Captain Wales, who with other UK and Isaf personnel was under lockdown."
A number of aircraft, hangars and other buildings at the base were hit and badly damaged by insurgent fire.
Major Martyn Crighton, from Isaf, said: "Nobody would deny that the insurgents are opportunistic.
"Isaf's facilities are very safe places, it just so happens that last night insurgents were able to make a spectacle of themselves and cause some damage.
"But there wasn't any real threat that it was under attack from a large group of insurgents."
Maj Crighton described the attack as "complex", in that insurgents used AK47-type weapons as well as mortars or rockets.
It is understood the militants managed to breach Camp Bastion's perimeter using rocket-propelled grenades before being driven back by forces inside the camp.
But he said there was no evidence to suggest whether the attack had been planned in advance or if it was simply opportunistic.
Major Charles Heyman, a former infantry officer and military analyst, said he believed the Taliban's motive was the anti-Islamic video rather than to target Harry.
"On balance it is probable that they are grandstanding a bit, but the real reason that attack was mounted was to coincide with all the riots and all the protests that have been going on across the world," he told Sky News.
Maj Heyman added that military officials should not withdraw the prince from Afghanistan.
"On balance I think the right move is to keep him there and let's just get on with it and get on with what we have to do for the next year and a half or so," he said.
An MoD spokesman said: "As Isaf has confirmed there was a significant attack on Camp Bastion yesterday evening. The attack was launched by a number of insurgents on the eastern side of the runway and there has been some damage to equipment which is still being assessed.
"After swift action by Isaf forces, including UK personnel, the incident was contained with a number of insurgents killed as a result. A clearance operation including UK and Isaf forces is being conducted and we are in the process of accounting for our people, who were subject to a lockdown as is the case when a base is attacked.
"Isaf have confirmed that two US Marine Corps service personnel were killed and that there were some other Isaf casualties.
"With daylight, work to assess and investigate the attack continues and further details will be made as and when available."
Harry, who celebrates his 28th birthday today, arrived in Afghanistan on September 7.
He has been undergoing training to fly operations in Apache attack helicopters and is expected to start flying missions this week as a co-pilot gunner.
Camp Bastion is a huge base in the middle of the desert and is shared with US, Estonian, Danish and Afghan troops.
It is the logistics hub for operations in Helmand, with supply convoys and armoured patrols regularly leaving its heavily-defended gates, to support the military forward operating bases, patrol bases and checkpoints spread across the province.
The MoD spokesman added: "The threat to all our service personnel is continually assessed and all measures taken to mitigate it.
"As we stated last week, the deployment of Captain Wales has been long planned and the threat to him and others around him thoroughly assessed.
"We stated that any risk posed by his deployment, based on the capability, opportunity and intent of the insurgency, is continually reviewed.
"As Isaf has confirmed, last night's attack was dealt with swiftly by Isaf personnel, including UK forces, and a number of insurgents were killed.
"A clearance operation has been conducted and work to assess and investigate the incident continues."
Isaf confirmed that 18 insurgents were killed in the attack, and one was captured.
Contextual targeting label: