Media playback is unsupported on your device Media caption Prime Minister David Cameron: "These brave soldiers were demonstrating great courage"

Three British soldiers have been killed by a policeman in southern Afghanistan, the Ministry of Defence (MoD) has said.

Two served with the 1st Battalion Welsh Guards and one with the Royal Corps of Signals. Next of kin have been told.

The MoD said the soldiers were shot and fatally wounded on Sunday as they left a checkpoint in Helmand province. The gunman was injured and later detained.

More than 20 foreign personnel have been killed in rogue shootings in Afghanistan this year.

Such shootings are sometimes referred to as "green on blue" attacks because of the colours representing Afghan (green) and Nato (blue) forces.

The soldiers were part of a Nato-led Isaf force who have been training Afghan counterparts ahead of a handover of security responsibility by 2014.

The shooting happened at Checkpoint Kamparack Pul in Nahr-e-Saraj, where the soldiers were attending a meeting of elders.

They were shot as they were leaving the checkpoint.

Sources told the BBC a fourth British soldier was injured in the shooting but was not seriously hurt.

Analysis The rise in "green on blue" killings this year does have an impact on trust in a relationship that is key for Nato exit strategy. British forces work and live closely alongside both the Afghan army and police forces. It is a proximity that commanders say is unavoidable if they are to advise and mentor the Afghan security forces effectively, as Nato begins its gradual withdrawal with the aim of finishing Isaf combat missions by the end of 2014. Nato forces have taken extra security measures in response to incidents earlier in the year, such as assigning "guardian angels" - soldiers who remain armed on their base to watch over their comrades as they sleep. Afghans have also stepped up their internal security measures, putting agents into units to check and monitor the loyalties of those serving in the Afghan police and army, especially when they return from periods of leave.

Prime Minister David Cameron said he was "deeply saddened by the appalling news".

"This tragic incident again demonstrates the very real risks that our brave soldiers face every day. We will do everything possible to find out how this happened, and learn any lessons for the future," he said in a statement.

Leader of the Opposition, Ed Miliband, told the Commons the deaths reminded them of "our duty to do everything we can to protect" UK troops.

Defence Secretary Philip Hammond signalled that the killings would not prompt an overall change of strategy.

He said: "Every day, tens of thousands of coalition forces, including UK personnel, live and work successfully with their Afghan counterparts to build an Afghan police force and Army which can take the lead for their own security by the end of 2014.

"That process will continue, and though deeply tragic, yesterday's incident and attacks like it will not derail the mission or distract us from the task in hand."

His sentiments were echoed by Nato secretary-general Anders Fogh Rasmussen said who said the Taliban had "played out a strategy" to undermine confidence in the Afghan security forces but he stressed that the insurgents could not "derail" his organisation's strategy.

BBC defence correspondent Caroline Wyatt said that background checks are carried out on Afghan troops and police in a bid to ensure that people are not sympathetic to insurgent factions.

But Mark Cann, spokesman for the British Forces Foundation charity, said soldiers were worried about how Afghan colleagues, particularly police, were vetted.

'More cautious'

And the BBC's Quentin Sommerville said the shooting, and other "green on blue" killings, meant the trust between international troops and their Afghan counterparts was diminished.

"It makes everybody a little more cautious," he said.

"They [Isaf soldiers] need to know that the man standing to their left and their right is someone they can trust and with these kinds of incidents that has deteriorated."

Green on blue deaths So far this year there have been 26 "green on blue" deaths - mostly Americans

There were 35 such deaths during 2011

The attacks have claimed the lives of 14 British service personnel since 2009

About 130,000 coalition troops are fighting alongside 350,000 Afghan security personnel against the Taliban-led insurgency

The deaths were announced by a spokesman for Task Force Helmand who said: "Their loss will be felt deeply across the task force. However, that will be nothing compared with the grief experienced by their families at home.

"Our thoughts and prayers are with them at this extremely difficult time."

The attack appears to be the latest in a string of flashpoints in which members of the Afghan security or police forces have opened fire on international allies.

The latest deaths mean a total of 26 Isaf personnel have been killed so far this year, compared with 35 for the whole of 2011.

A total of 14 British troops have been killed in the past three years in Green on Blue attacks.

In February, public opinion against the foreign forces in Afghanistan was inflamed by revelations that US troops burned copies of the Koran at a base in Afghanistan - reportedly by accident.

The shooting of 16 Afghans by a US soldier in March has also created resentment.