Five British nationals and a UK resident are believed dead or missing after the Algeria hostage crisis reached a violent and bloody climax.
Algerian special forces mounted a "final assault" on the last Islamist militants holding out at the remote BP gas plant at In Amenas on Saturday, bringing to an end the four-day stand-off in the desert.
Afterwards the Algerian interior ministry reported that, in all, 23 hostages and all 32 terrorists had died, while 107 foreign workers and 685 local employees had been released.
The Algerian authorities were working to dismantle explosives left by the terrorists who booby-trapped the sprawling plant before the final shoot-out.
The interior ministry strongly defended the rescue operation, despite criticism of the high death toll.
Freed British hostages Peter (left) and Alan (right). No surnames available
"To avoid a bloody turn of events in response to the extreme danger of the situation, the army's special forces launched an intervention with efficiency and professionalism to neutralise the terrorist groups that were first trying to flee with the hostages and then blow up the gas facilities," it said in a statement.
It said that troops had recovered an arsenal of six machine guns, 21 rifles, two shotguns, two 60mm mortars with shells, six 60mm missiles with launchers, two rocket-propelled grenades with eight rockets and 10 grenades in explosive belts.
The state news agency, APS, reported that the terrorists had killed seven of the hostages they were still holding before they were killed themselves by the special forces.
David Cameron said he had spoken to Algerian prime minister Abdelmalek Sellal, who confirmed that the military operation against the terrorists was "effectively ended".
In a statement, the Prime Minister added: "It is our priority now to get people home as quickly as possible and to look after the survivors. Many are already home or on their way back.
Algerian police escort freed Norwegian hostage Oddvar Birkedal
"Let me be clear. There is no justification for taking innocent life in this way.
"Our determination is stronger than ever to work with allies right around the world to root out and defeat this terrorist scourge and those who encourage it."
Foreign Secretary William Hague said that on the basis of the available information they believed five British nationals and a UK resident were either "deceased or unaccounted for" - in addition to the Briton killed on the opening day of the terrorist attack.
He insisted that it was too early to come to any judgement about the Algerian operation.
"I don't want to at this stage enter into criticism or judgement because there will be a lot to be learned yet about this operation," he said.
Japan's Prime Minister tells reporters 10 Japanese workers remain missing
In contrast, French president Francois Hollande gave his immediate backing to Algeria's tough tactics, saying they were "the most adapted response to the crisis".
Several hours after the troops stormed the gas plant, President Barack Obama said the US was seeking from Algerian authorities a fuller understanding of what took place, but added that "the blame for this tragedy rests with the terrorists who carried it out".
Meanwhile, 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.
The situation at the plant remains unclear and 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," he said.
An Algerian army truck in a street of In Amenas, near the gas plant
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.
The kidnappers, who call themselves 'Those Who Sign In Blood', had earlier told a Mauritanian news agency 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, however, insisted that they had to act immediately amid fears that the militants were about to flee into the desert, taking hostages with them.
Defence Secretary Philip Hammond with US Secretary of Defence Leon Panetta
By Friday it was 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 kidnappers, part of the Masked Brigade - a terrorist splinter group led by the veteran jihadist, Mokhtar Belmokhtar, which broke away from al Qaeda in the Islamic Maghreb - initially claimed the attack was in retaliation for the French military intervention in neighbouring Mali.
It was subsequently reported that they were demanding the release of two terrorists held in the US, including 1993 World Trade Centre bombing mastermind Omar Abdel Rahman, in return for the release of two US captives.
The plant at In Amenas is jointly operated by BP, Norwegian company Statoil and Algerian state oil company Sonatrach.
Algerian police guard the entrance of a hospital located near the gas plant
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."
The family of British survivor Darren Matthews, from Saltburn-by-the-Sea in Cleveland, expressed their relief that he had escaped unhurt.