David Cameron has confirmed that three British nationals have been killed in Algeria, a further three are believed to be dead and a British resident has also died.
Five suspected members of the Islamist group behind the attack have been arrested at the In Amenas gas plant, reports the BBC.
The remaining 22 British survivors have returned to the UK and been reunited with their loved-ones, the Foreign Secretary has confirmed.
Cameron said: "I know the whole country will want to join me in sending our sympathies and condolences to the families who have undergone an absolutely dreadful ordeal and who now face life without these very precious loved ones.".
The PM speaking From Chequers on Sunday morning
Speaking from Chequers, the PM echoed President Barack Obama and blamed the terrorists for the deaths, saying "of course people will ask questions about the Algerian response to these events, but I would just say that the responsibility for these deaths lies squarely with the terrorists who launched a vicious and cowardly attack."
Scotland's First Minister Alex Salmond said that two Scots, or people with immediate Scottish family connections, were believed to have been killed. There were eight Scots among the survivors.
"The Scottish authorities continue to offer every support to all caught up in this crisis, and we remain in close contact with the UK Government," he said.
Despite the high death toll - with 23 hostages and 32 terrorists known to have died - the Prime Minister refused to criticise the uncompromising stance taken by the Algerian government.
"When you are dealing with a terrorist incident on this scale with up to 30 terrorists it is extremely difficult to respond and get this right in every respect."
Mr Cameron added: "We should recognise all that the Algerians have done to work with us and to help and co-ordinate with us, and I would like to thank them for that.
"We should also recognise that the Algerians too have seen lives lost amongst their soldiers. I think it is very important to make that point."
William Hague, who appeared on the Andrew Marr show this morning, told Jeremy Vine that the Algerian foreign minister had feared the terrorists were going to "blow up the entire installation" and that the lives of the hostages were always in imminent danger, before the crisis came to its bloody climax.
Hague said it was likely the hostages were executed
He told Vine, who is standing in for Andrew Marr while he recovers from his stroke, told it was "likely" the hostages were executed.
Cameron said in a statement the attack was a "stark reminder" of the continuing terrorist threat, adding: "It is linked to al Qaida, it wants to destroy our way of life, it believes in killing as many people as it can.
He vowed to use Britain's chairmanship of the G8 to ensure that it was right at the top of the international agenda.
"This is a global threat and it will require a global response. It will require a response that is about years, even decades, rather than months," he said.
He said that there were clear similarities with the terrorist threat from Afghanistan and Pakistan, even though it was on a different scale.
"What we face is an extremist, Islamist, al Qaida-linked terrorist group. Just as we had to deal with that in Pakistan and in Afghanistan so the world needs to come together to deal with this threat in north Africa," he said.
"We need to work with others to defeat the terrorists and to close down the ungoverned spaces where they thrive with all the means that we have."
A number of British hostages have already been released
Algerian special forces yesterday mounted a "final assault" on the last Islamist militants holding out at the remote BP gas plant at In Amenas, bringing to an end the four-day stand-off in the desert.
The Algerian interior ministry said that since the crisis began on Wednesday, 23 hostages and all 32 terrorists had died, while 107 foreign workers and 685 local employees had been released.
Named only as Peter and Alan, two Britons after being 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 kidnappers are linked to a terrorist splinter group led by veteran jihadist Mokhtar Belmokhtar
In the face the of the high death toll, the interior ministry said last night that troops had no choice but to intervene.
"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.
Troops later recovered a terrorist 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.
Earlier, the state news agency APS reported had that the militants had killed seven of the hostages they were still holding before they were killed by the special forces.
Mr Cameron said that Algerian prime minister Abdelmalek Sellal had confirmed to him that the terrorist incident was "effectively ended".
"I know that the whole country shares my sympathy and concern for everyone who has been caught up in this incident, and for their friends and families," the Prime Minister said in a statement.
"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."
The British ambassador to Algiers, Martyn Roper, yesterday arrived in In Amenas alongside a UK consular team, after finally being granted permission to fly to the region.
President Barack Obama has said the US was ready to provide whatever assistance was needed in the wake of the attack.
"This attack is another reminder of the threat posed by al Qaida and other violent extremist groups in North Africa," he said in a statement.
Defence Secretary Philip Hammond said: "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."
The kidnappers, part of the Masked Brigade - a terrorist splinter group led by the veteran jihadist, Mokhtar Belmokhtar, which broke away from al Qaida 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.
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.
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."