Gunman killed by return fire during attack in provincial capital Lashkar Gah, in latest sign of growing tensions in Afghanistan

Two British soldiers were killed on Monday when an Afghan soldier turned his gun on them at the gates of a UK military base.

The attacker was also killed during an exchange of fire which may have started after security guards stopped a truck as it tried to enter the heavily fortified compound in Helmand's capital Lashkar Gah.

The incident comes amid heightened tension in Afghanistan following incidents involving US troops such as the killing of 17 Afghan civilians by an American soldier.

In the past seven weeks 10 British soldiers have died on duty in Helmand, though David Cameron and the defence secretary, Philip Hammond, have made clear they intend to resist mounting calls for western forces to come home early.

The latest incident is a "green on blue" attack – when a member of the Afghan security forces has killed an ally from Nato's International Security and Assistance Force (Isaf).

The Ministry of Defence said the victims were a Royal Marine and a member of the Adjutant General's Corps. Their close relatives have been informed.

An Afghan police official said the shootings took place when an Afghan army truck approached the base and was reportedly refused entry by the guards. The official said one of the Afghan soldiers then rushed through the gates and opened fire on those inside, killing the two Britons.

"Details of the incident are still emerging but it appears that a member of the Afghan National Army opened fire at the entrance gate to the British headquarters," Hammond told the House of Commons. "The assailant was killed by return fire."

Brigadier General Sherin Shah, of the Afghan National Army said: "Today's incident which involved armed conflict by one of the ANA members of the Fourth Kandak of 3-215 Brigade was a tragic event.

"The incident is still under investigation and it is unclear if the action was planned or influenced by the enemy or if he acted alone, either way it is with the deepest regret that two Isaf soldiers who came to our country to provide security are now dead.

"I would like to convey my deepest condolences to the soldiers' families and the British Army and Royal Marines, especially Task Force Helmand, for their loss."

Tensions have been running high in Afghanistan because of the burning of Qur'ans by US forces inside an international base, and then the shooting dead of 17 Afghan civilians in Kandahar province by Staff Sergeant Robert Bales.

Isaf commanders have been anticipating a backlash from the Taliban, though it is unclear whether this latest shooting involved an infiltrator or someone who acted on the spur of the moment.

Massoud Khan Nourzai, an MP from Helmand, said:"These kinds of attacks have increased lately and maybe they will continue to increase in the future.

"They have increased because of the incidents like the one in Kandahar. If an incident like Kandahar happens, people are not sitting quietly. In every Afghan family they are talking about it and saying they committed a cruel action."

Nourzai added that in the past two years many of his relatives have stopped working with the government and joined forces with the Taliban primarily because of their frustration with the continuing presence of foreign forces.

Sardar Mohammad Khan, a teacher in Lashkar Gah, said the attack was "a result of the foreigners' behaviour and activities", adding: "Everyone is frustrated – the army, the police, normal Afghans. On one side we are frustrated with our own government, the corruption, the insurgency, and the return of the Taliban.

"On the other side, when the foreigners are doing such things it makes you even more frustrated."

The issue of attacks by Afghan soldiers poses a sizeable threat to Isaf. One military report found Afghan security forces were responsible for 6% of coalition casualties between May 2007 and May 2011.

In January, France temporarily suspended its combat operations and threatened a premature withdrawal after someone in an Afghan military uniform killed four French soldiers.

Maintaining foreign support remains vital for the Afghan military, which will require an estimated $6bn (£3.7bn) to continue operating after foreign troops leave in 2014.

Following the shooting in Kandahar, American officials have sought to appease Afghans by providing assistance to the families of the victims. Families reportedly received $50,000 (£31,400) for each person killed and $11,000 (£6,900) for those who were wounded.

Xenia Dormandy, a senior fellow at Chatham House, said the UK soldiers may have been caught in the backlash against US forces.

She said: "It is not clear that they make a distinction between US forces and Isaf soldiers, so at some level this is really not that surprising that this would occur. It is just extraordinarily sad that it does.

"As for the question: 'Does this mean that the UK should pull out its forces?' Absolutely not. I think Cameron has made it absolutely clear that he does not intend to before the organised roll-out in 2014."