British officials were tonight trying frantically to establish the fate of the remaining UK hostages at the Algerian gas plant as the four-day stand-off came to a violent and bloody end.

Seven hostages were reported to have died as Algerian special forces mounted a final assault on remaining Islamist militants holding out at the remote BP-operated facility.

First Minister Alex Salmond said eight Scottish residents are confirmed safe and secure but said some of the workers still unaccounted for have family in Scotland or other connections to here.

Downing Street said that David Cameron has spoken to Algerian prime minister Abdelmalek Sellal who confirmed that the operation is now over. The ambassador is now at In Amenas, a No 10 spokesman said.

A second meeting of the Government's Cobra emergencies committee is now under way in Whitehall.

Defence Secretary Philip Hammond disclosed that they had been informed by the Algerians that the military operation was now at an end.

"We are pressing the Algerians for details on the exact situation and the numbers that have been killed and, if any, the numbers rescued," he told a joint news conference with US Secretary of State Leon Panetta.

"The loss of life as a result of these attacks is appalling and unacceptable. We must be clear that it is the terrorists who bear sole responsibility for it."

BP chief executive Bob Dudley said the company was "unable to confirm the location or situation" of four employees at In Amenas and had "grave fears" that they are likely to have suffered fatalities.

Earlier, Foreign Secretary William Hague said that while the majority of the British workers were safe "fewer than 10" were "at risk or unaccounted for".

"But that of course means that we must continue to prepare ourselves for bad news," he said.

Algerian state news agency APS reported that 11 militants died in the final battle. It quoted a security source as saying that the hostages who died were killed by their captors.

The Foreign Office said in a statement "The Algerian authorities have confirmed to us that the military phase of the operation to resolve this crisis has concluded.

"The site is still being made safe by the Algerian authorities and we are urgently continuing our work to establish the status of the British nationals caught up in this incident."

Mr Hague said a British consular team is now on the ground at In Amenas, providing assistance to those Britons who escaped, while the ambassador Martyn Roper is travelling to the area.

"This whole incident underlines the scale and ruthlessness of the terrorist threat that we and other nations face," he said.

"We underline our resolve to deal with that and to defeat terrorism and murder, working with allies across the world including in north Africa."

The situation at the plant remains unclear, with reports that 16 foreign nationals, including two Americans, two Germans and a Portuguese person, were freed.

Mr Dudley said that it could be some time before they establish exactly what happened. Two BP employees suffered injuries although they are not life-threatening.

"Our focus remains on our colleagues, who we have not yet been able to locate, and on supporting their families through a time of agonising uncertainty. BP is a company that cares about its people. This is a difficult and sad time for us all," he said.

He said 25 of the 56 BP workers in Algeria at the time of the attack have now left in a "staged process" of withdrawing all non-essential staff from the country.

Earlier the kidnappers, who call themselves the Masked Brigade or "The Signers in Blood", told a Mauritanian news agency they are in contact with that they were holding seven foreigners: one British, three Belgians, two Americans and one Japanese.

The drama began on Wednesday when a group of about 30 heavily armed militants mounted a dawn raid at the plant close to the Libyan border, seizing hostages from among the 700 Algerian and foreign workers at the site.

Two workers, including one Briton, died in the initial assault.

The following day Algerian special forces mounted an operation to take back the plant, to the initial dismay of the British and other governments who were not notified in advance despite offering assistance to the Algerian authorities.

The Algerians insisted that they had to act immediately amid fears that the militants were about to flee into the desert, taking hostages with them.

By Friday APS reported that about 100 foreigners, from a total of 132, and 573 Algerians were freed, with a "provisional" figure of 12 hostages and 18 militants killed in the fighting, although the kidnappers claimed 35 foreigners died.

But it was also clear that a group of militants, still holding hostages, was continuing to hold out.

The plant at In Amenas is jointly operated by BP, Norwegian company Statoil and Algerian state oil company Sonatrach.

Despite the casualties among the hostages, an Algerian government source quoted yesterday by APS strongly defended the military operation, saying it prevented a "true disaster" which would have caused "immeasurable" human and material damage.

The rescue mission was carried out in "extremely complex circumstances" against terrorists armed with a huge arsenal of missiles, rocket launchers, grenades and assault rifles, the source said.

Swift action was the "only way to minimise or neutralise the deadly intent of the multinational terrorists - but not without the inevitable risks in all such situations".

It has been reported that two UK workers are among the casualties, which would bring the British death toll to three. One was killed in Wednesday's initial raid by the militants.

As freed hostages began to leave the plant, accounts emerged of their horrific treatment at the hands of the kidnappers.

One Algerian worker, who gave his name only as Chabane, described how from his hiding place he heard the militants speaking among themselves with Libyan, Egyptian and Tunisian accents. At one point, he said, they caught a Briton.

"They threatened him until he called out in English to his friends, telling them 'Come out, come out. They're not going to kill you. They're looking for the Americans'," he said.

"A few minutes later they blew him away."