Islamist gunmen killed seven foreign hostages in Algeria on Saturday before being gunned down by Special Forces in a final assault on a remote desert gas complex, state television said.
The 11 heavily armed men from a group known as "Signatories in Blood" had been holed up at the In Amenas complex since they took hundreds of workers hostage in a dawn attack on Wednesday.
Most of the hostages, including about 100 foreigners, had been freed after the Algerian forces launched a bloody 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 TV said. It did not give the nationalities of those who died.
As army helicopters overflew the gas plant, a security official gave the same toll for both the captors and hostages killed, adding it was believed "they were killed in retaliation".
The gunmen, cited by Mauritania's ANI news agency, had said earlier they were still holding "seven foreign hostages".
On Friday, they had given a breakdown of three Belgians, two Americans, one Japanese and a Briton still captive, although Brussels said there was no indication any of its nationals were being held.
An Algerian security official had put the remaining number of foreign hostages at 10.
Norway's Statoil, which jointly operates the In Amenas site with Britain's BP and Sonatrach of Algeria, said two Norwegians have been found alive but six others were missing.
After the assault, a security official said 25-27 foreign and Algerian hostages had been killed over the four-day crisis, but the exact number of those seized and still unaccounted for was unclear.
On Friday, an official had said troops were trying to reach a "peaceful" end to the crisis, before "neutralising the terrorist group that is holed up in the plant and freeing a group of hostages still being held there."
Amid what had been a virtual news blackout in Algiers, harshly criticised by local media, world leaders took a tough stand on the fate of the remaining hostages.
US Defence Secretary Leon Panetta said Washington would "take all necessary steps to protect our people" from the threat of Al-Qaeda-affiliated militants in North Africa.
Earlier, US Secretary of State Hillary Clinton spoke of her deep concern "about those who remain in danger. Utmost care must be taken to preserve innocent life."
At least one American had already been confirmed dead before Saturday's final assault.
In Tokyo, Prime Minister Shinzo Abe ordered his government to do everything possible to ensure the safety of those Japanese unaccounted for in "an extremely despicable" incident that "can never be forgiven".
"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 spokeswoman 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.
Of the French intervention in Mali, Foreign Minister Laurent Fabius said at a meeting in Abidjan on Saturday that "France was obliged to intervene very, very rapidly, otherwise there would have been no more Mali".
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 said, 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.'"
Algeria's El Watan daily quoted a former military officer as justifying the army's assault on Thursday, saying: "All hesitation is forbidden when the future of the nation is at stake or being threatened."
The final death tolls, of both foreign and Algerian hostages and of gunmen, was not yet known.