The Ministry of Defence said the policeman “turned on” the soldiers inside a military compound.

Sources named the attacker as a man called Gulbuddin and suggested he was connected to the Taliban,

A ministry statement said: “The soldiers were all killed as a result of gunshot wounds sustained in an attack on November 3.”

The soldiers, three from the Grenadier Guards and two from the Royal Military Police, died in the Nad-e’Ali district of Helmand Province .

A UK military spokesman said: “Initial reports suggest that it was a member of the Afghan National Police who fired without warning.

“The incident happened at a checkpoint and he fired before anyone could respond.

“This matter is subject to a parallel investigation between the British Military Police and the Afghan Police.

“It’s our understanding that one individual Afghan National Policeman, possibly in conjunction with another, went rogue.

“His motives and whereabouts are unknown at this time.

“Every effort is now being put into hunting down those responsible for this attack.”

As well as the investigation by the British Military Police, the local chief of the ANP and the Afghan National Director of Security (NDS) have begun an investigation at the scene.

The Grenadier Guards were working in a so-called Omelette team, helping to advise the ANP and Afghan National Army in training, tactics and patrol methods.

Army spokesman Lieutenant Colonel David Wakefield said: “The soldiers concerned were mentoring Afghan police. They were working inside and living inside an Afghan national police checkpoint.”

He said: “It would appear, and it is our initial understanding, that an individual Afghan policeman possibly acting with another started firing within the checkpoint before fleeing the scene.”

He stressed that the attack did not come as a result of any breakdown or fight between British and Afghan forces.

The gunman’s whereabouts were unknown but British forces were making every effort to find him, military officials said.

The British casualties were evacuated to the hospital at Camp Bastion.

Several wounded men were flown in by Medical Emergency Response Teams using Chinook helicopters and a US Black Hawk.

The injured were rushed from the landing pad to the emergency department by ambulance where hospital medics and consultants were waiting en masse.

The military spokesman said two ANP casualties were also evacuated by the ANP to the hospital at Bost in Lashkar Gah.

The MoD said the attack is “subject to investigation”. next of kin have been informed.

Prime Minister Gordon Brown paid tribute to the soldiers describing their deaths as a “terrible loss”.

“My thoughts, condolences and sympathies go to their families, loved ones and colleagues. I know that the whole country too will mourn their loss,” he said.

“They fought to make Afghanistan more secure, but above all to make Britain safer from the terrorism and extremism which continues to threaten us from the border areas of Afghanistan and Pakistan.

“I pay tribute to their courage, skill and determination. They will never be forgotten.

“It is my highest priority to ensure our heroic troops have the best possible support and equipment - and the right strategy, backed by our international partners, and by a new Afghan government ready to play its part in confronting the challenges Afghanistan faces.

“Our troops deserve nothing less. My commitment to them remains unshakeable.”

Defence Secretary Bob Ainsworth offered his condolences to the families of the soldiers and emphasised the need for the country to show “resolve” in supporting the Afghan mission.

“I was extremely saddened to hear of the deaths of these courageous soldiers. My very deepest condolences go out to their families, friends and colleagues as they come to terms with the loss of these outstanding men,” he said.

“It continues to be a difficult year in Afghanistan for our brave people who are operating within the most challenging area of the country.

“We owe it to them to show the resolve that they exhibit every day in building security and stability in Afghanistan and protecting the UK from the threat of terrorism.”

Tory leader David Cameron said: “I was deeply shocked to hear of the deaths of five British soldiers in a single incident in Helmand Province, and the horrific circumstances in which it appears they died.

“I pay tribute, as will the whole country, to their professionalism and their courage, and send my condolences to their families and their friends.”