KABUL, Afghanistan – An Afghan soldier killed three British service members with gunfire and a rocket-propelled grenade in the dead of night, a betrayal that highlights the difficulties in rapidly building up Afghan security forces so that foreign troops can go home.

The soldier fled the base after carrying out the attack in southern Afghanistan early Tuesday, leaving his motive unclear. But the Taliban claimed that he was a militant sympathizer who was taken in by insurgents after the assault — one that could further weaken support in Britain for an unpopular war that has now taken the lives of 318 Britons.

In London, Prime Minister David Cameron condemned the killings as “appalling” but insisted the attack should not change NATO’s strategy of working alongside the Afghan army.

Four other British service members were wounded in the attack on a base in northern Helmand province that is home to members of the 1st Battalion Royal Gurkha Rifles.

Separately, the British Ministry of Defense reported that a fourth British service member — a Royal Marine from 40 Commando Royal Marines — was shot and killed while on foot patrol in Sangin district, which is next to Nahr-i-Saraj district where the attack by the Afghan soldier happened.

It was the second time in eight months that an Afghan turned against British troops partnering with local security forces. In November, an Afghan policeman killed five British soldiers at a checkpoint in Helmand.

Afghan police in the past have also attacked American soldiers and their own police stations, though such intentional attacks are rare.

Still, Tuesday’s attack comes at a time when the international coalition is ramping up training of Afghans so they can ultimately take responsibility for securing and defending the nation.

The speed with which Afghan security forces are growing — the allies set an interim goal of expanding the Afghan army from 85,000 in 2009 to 134,000 troops by October 2011 — has raised concerns about infiltration by the Taliban and the professionalism of the recruits. It remained unclear how long Tuesday’s attacker had been enlisted in the Afghan National Army, whether he plotted the assault with others and what motivated him to carry out the killings — which Britain’s Ministry of Defense called a “suspected premeditated attack.”

Lt. Col. James Carr-Smith, spokesman for the coalition task force in Helmand province, said: “We believe these were the actions of a lone individual who has betrayed his NATO and Afghan comrades.

“His whereabouts are currently unknown, but we are making strenuous efforts to find him.”

There were few details about how the attack unfolded. The British Defense Ministry said the Afghan soldier used “a combination of weapons.”