A still image broadcast by Algeria's Ennahar TV shows hostages surrendering to Islamist gunmen who overtook a gas facility in Tiguentourine near In Amenas in the south of the country.
The 11 heavily armed men from a group known as "Signatories in Blood" had been holed up at the remote In Amenas complex near the Libya border since they took hundreds of workers hostage in a dawn attack on Wednesday.
Most of the hostages, including 573 Algerians and about 100 foreigners, had been freed after Algerian forces launched a rescue operation on Thursday, which was widely condemned as hasty, but some 30 remained unaccounted for.
In Saturday's final assault, "the Algerian army took out 11 terrorists, and the terrorist group killed seven foreign hostages," state television said, ending one of the bloodiest international hostage crises in years.
It did not give the nationalities of those who died.
A security official who spoke to Agence France-Presse (AFP) as army helicopters flew over the plant deep in the Sahara near the Libyan border, gave the same death tolls, adding that it was believed the foreigners "were killed in retaliation".
British Defence Secretary Philip Hammond said the four-day crisis had been "brought to an end by a further assault by Algerian forces, which has resulted in further loss of life".
"We're pressing the Algerians for details on the exact situation," said Hammond.
The deaths were "appalling and unacceptable and we must be clear that it is the terrorists who bear sole responsibility for it," he told a news conference with his US counterpart Leon Panetta.
The hostage-taking was the largest since the 2008 Mumbai attack, and the biggest by jihadists since hundreds were killed in a Moscow theatre in 2002 and at a school in the Russian town of Beslan in 2004, according to monitoring group IntelCenter.
Foreign Secretary William Hague said Britain must prepare itself for "bad news," and that "the large majority" of Britons originally caught up in the crisis were safe, with "fewer than 10" at risk or unaccounted for.
The final death tolls, of both foreign and Algerian hostages and of gunmen, were not yet known.
The gunmen, cited by Mauritania's ANI news agency, had said earlier they were still holding "seven foreign hostages".
They had given a breakdown of three Belgians, two Americans, one Japanese and a Briton, although Brussels said there was no indication any of its nationals were being held.
A security official had put the remaining number of foreign hostages at 10.
'To defeat terrorism'
After the assault, a security official said 25 to 27 foreign and Algerian hostages had been killed during the four-day crisis, but the exact number of those seized and still unaccounted for was unclear.
With the crisis over, experts began to clear the complex of bombs planted by the Islamists, said Sonatrach, the Algerian firm that runs the gas plant jointly with Britain's BP and Norway's Statoil.
Amid what had been a virtual news blackout in Algiers, harshly criticised by local media, world leaders had taken a tough stand on the fate of the remaining hostages.
But Panetta refused to criticise Algeria.
"They are in the region, they understand the threat from terrorism … I think it's important that we continue to work with (Algiers) to develop a regional approach."
At least one American had already been confirmed dead before Saturday's assault.
Algeria's El Watan daily quoted a former military officer as justifying the army's assault, saying: "All hesitation is forbidden when the future of the nation is at stake or being threatened."
"Signatories in Blood," led by Algerian Mokhtar Belmokhtar, a former senior Al-Qaeda commander in north Africa, were demanding an end to French intervention against Islamists in neighbouring Mali, ANI reported earlier.
Belmokhtar also wanted to exchange American hostages for the blind Egyptian sheikh Omar Abdul Rahman and Pakistani Aafia Siddiqui, jailed in the United States on charges of terrorist links.
But State Department spokesperson Victoria Nuland said "the United States does not negotiate with terrorists".
France, which said on Saturday that 2 000 of the 2 500 troops it had pledged were now on the ground in Mali, said that no more of its citizens were being held.
President Francois Hollande said French troops would stay in Mali as long as is needed "to defeat terrorism" in the West African country and its neighbours.
Algerian news agency APS quoted a government official as saying the kidnappers, who claimed to have come from Niger, were armed with machineguns, assault rifles, rocket launchers and missiles.
This was confirmed by an Algerian driver, Iba El Haza, who said the hostage-takers spoke in different Arabic dialects and perhaps also in English.
"From their accents I understood one was Egyptian, one Tunisian, another Algerian and one was speaking English or (another) foreign language," Haza told AFP, two days after escaping during the army's Thursday attack.
"The terrorists said: 'You have nothing to do with this, you are Algerians and Muslims. We won't keep you, we only want the foreigners.'" – AFP.