Afghan intelligence spokesman Shafiqullah Tahiri said the kidnappers hoped killing one of the hostages would force negotiators to accept their demands. Photograph: AP

The gunmen who abducted four aid workers in north Afghanistan were making plans to move the hostages across the border into nearby Tajikistan, or even kill one of them, to put pressure on negotiators, an Afghan intelligence official said.

Special forces launched the midnight operation to rescue 28-year-old Briton Helen Johnston and her three colleagues after learning that their lives could be at risk, said Shafiqullah Tahiri, spokesman for the Afghan intelligence service.

The militants hoped killing a hostage would impel negotiators to accept their demands of a $1m (£650,000) ransom and the release of five of their colleagues imprisoned in Kabul, Associated Press quoted Tahiri as saying. The insurgents initially asked for at least $4m before reducing their demand, he added.

The four employees of Swiss-based Medair were captured while travelling by donkey to flood-stricken areas of northern Badakhshan province on 22 May.

Johnston, originally from Belfast, is a nutritionist who graduated from the London School of Hygiene and Tropical Medicine. The other captives were 26-year-old Kenyan Moragwa Oirere and two Afghans who have not been named. A third Afghan escaped shortly after the group was abducted.

Their captors were armed with heavy machine guns, AK-47 assault rifles and rocket-propelled grenades. They moved the hostages from cave to cave in an area known locally as "ant valley" to avoid detection, Afghan officials said.

The top British commander in Afghanistan, Lieutenant General Adrian Bradshaw, told the BBC that rescuers had to operate in "some of the most demanding country on the planet.

"They had to cover the ground very rapidly … The terrain was an incredibly difficult terrain, very rocky, with scrub, in a deep gully – it was about the most testing target you could imagine.

"It does take real skill and there are real risks involved in this sort of operation, and we wouldn't have done it were there not a very clear threat to the lives of the hostages, which there was."

David Cameron, who authorised the mission, said it showed kidnappers of British citizens faced a "swift and brutal end".

Eight militants were killed in the operation, launched after Afghan intelligence services provided Nato forces with precise details about the hostages' location, Tahiri said. No Afghan or Nato forces were harmed.

Rescue attempts in Afghanistan have not always gone so well. In 2009, Sultan Munadi, an Afghan journalist working for the New York Times, was kidnapped with colleague Stephen Farrell, and then shot dead during a rescue attempt by British commandos.

A British soldier from 3rd Battalion, the Yorkshire Regiment, has been killed in Afghanistan, the Ministry of Defence has said. He was shot while on patrol in the south of Nahr-e Saraj district in Helmand province and is the 417th member of UK forces to have died since operations in Afghanistan began in October 2001.

Hours earlier, a British soldier from 1st Battalion, the Royal Welsh, who was killed in Afghanistan on Friday, was named as Corporal Michael John Thacker. He was manning an observation post in the Nahr-e Saraj district when his patrol came under attack from small arms fire. He was evacuated from the scene by helicopter but died of his injuries.

Sign up for the Guardian Today

Our editors' picks for the day's top news and commentary delivered to your inbox each morning.