Algerian forces stormed a desert gas complex to free hundreds of hostages but 30, including several Westerners, were killed in the assault along with at least 11 of their Islamist captors, an Algerian security source told Reuters.
Western leaders whose compatriots were being held did little to disguise their irritation at being kept in the dark by Algeria before the raid - and over its bloody outcome. French, British and Japanese staff were among the dead, the source said.
An Irish engineer who survived said he saw four jeeps full of hostages blown up by Algerian troops whose commanders said they moved in about 30 hours after the siege began because the gunmen had demanded to be allowed to take their captives abroad.
And while a crisis has ended that posed a serious dilemma for Paris and its allies as French troops attacked the hostage-takers' al Qaeda allies in neighbouring Mali, it left question marks over the ability of OPEC-member Algeria to protect vital energy resources and strained its relations with Western powers.
Two Japanese, two Britons and a French national were among at least seven foreigners killed, the source told Reuters. Eight dead hostages were Algerian. The nationalities of the rest, as well as of perhaps dozens more who escaped, were unclear. Some 600 local Algerian workers, less well guarded, survived.
Fourteen Japanese were among those still unaccounted for by the early hours of Friday, their Japanese employer said.
Americans, Norwegians, Romanians and an Austrian have also been mentioned by their governments as having been captured by the militants who called themselves the "Battalion of Blood" and had demanded France end its week-old offensive in Mali.
Underlining the view of African and Western leaders that they face a multinational Islamist insurgency across the Sahara - a conflict that prompted France to send hundreds of troops to Mali last week - the official source said only two of the 11 dead militants were Algerian, including the squad's leader.
The bodies of three Egyptians, two Tunisians, two Libyans, a Malian and a Frenchman were found, the security source said.
The group had claimed to have dozens of guerrillas on site and it was unclear whether any militants had managed to escape.
The overall commander, Algerian officials said, was Mokhtar Belmokhtar, a veteran of Afghanistan in the 1980s and Algeria's bloody civil war of the 1990s. He appears not to have been present and has now risen in stature among a host of Saharan Islamists, flush with arms and fighters from chaotic Libya, whom Western powers fear could spread violence far beyond the desert.
"NO TO BLACKMAIL"
Algeria's government spokesman made clear the leadership in Algiers remains implacably at odds with Islamist guerrillas who remain at large in the south years after the civil war in which some 200,000 people died. Communication Minister Mohamed Said repeated their refusal ever to negotiate with hostage-takers.
"We say that in the face of terrorism, yesterday as today as tomorrow, there will be no negotiation, no blackmail, no respite in the struggle against terrorism," he told APS news agency.
British Prime Minister David Cameron, who warned people to prepare for bad news and who cancelled a major policy speech on Friday to deal with the situation, said through a spokesman that he would have liked Algeria to have consulted before the raid.
A Briton and an Algerian had also been killed on Wednesday.
The prime minister of Norway, whose state energy company Statoil runs the Tigantourine gas field with Britain's BP and Algeria's national oil company, said he too was not informed.
U.S. officials had no clear information on the fate of Americans, though a U.S. military drone had flown over the area. Washington, like its European allies, has endorsed France's move to protect the Malian capital by mounting air strikes last week and now sending 1,400 ground troops to attack Islamist rebels.
A U.S. official said on Thursday it would provide transport aircraft to help France with a mission whose vital importance, President Francois Hollande said, was demonstrated by the attack in Algeria. Some fear, however, that going on the offensive in the remote region could provoke more bloodshed closer to home.
The apparent ease with which the fighters swooped in from the dunes to take control of an important energy facility, which produces some 10 percent of the natural gas on which Algeria depends for its export income, has raised questions, over the value of security measures that are outwardly draconian.
Foreign firms were pulling non-essential staff out of the country, which has recovered stability only in recent years and whose ruling establishment, heirs to fighters who ended French rule 50 years ago, has resisted demands for reform and political freedoms of the kind that swept North Africa in the Arab Spring.
"The embarrassment for the government is great," said Azzedine Layachi, an Algerian political scientist at New York's St John's University. "The heart of Algeria's economy is in the south. where the oil and gas fields are. For this group to have attacked there, in spite of tremendous security, is remarkable."
A local man who had escaped from the facility told Reuters the militants appeared to have inside knowledge of the layout of the complex, supporting the view of security experts that their raid was long-planned, even if the Mali war provided a motive.
"The terrorists told us at the very start that they would not hurt Muslims but were only interested in the Christians and infidels," Abdelkader, 53, said by telephone from his home in the nearby town of In Amenas. "'We will kill them,' they said."
Algiers, whose leaders have long had frosty relations with the former colonial power France and other Western countries, may have some explaining to do over its tactics in putting an end to a hostage crisis whose scale was comparable to few in recent decades bar those involving Chechen militants in Russia.
Government spokesman Said sounded unapologetic, however: "When the terrorist group insisted on leaving the facility, taking the foreign hostages with them to neighbouring states, the order was issued to special units to attack the position where the terrorists were entrenched," he told state news agency APS, which said some 600 local workers were freed.
The militants said earlier they had 41 foreign hostages.
"ARMY BLASTED HOSTAGES"
Stephen McFaul, an electrical engineer, told his family in Northern Ireland after the operation that he narrowly escaped death, first when bound and gagged by the gunmen who fastened explosives around the hostages' necks and then on Thursday when he was in a convoy of five vehicles driving across the complex.
"(The gunmen) were moving five jeeploads of hostages from one part of the compound," his brother Brian McFaul said. "At that stage, they were intercepted by the Algerian army.
"The army bombed four out of five of the trucks and four of them were destroyed ... He presumed everyone else in the other trucks was killed ... The truck my brother was in crashed and at that stage Stephen was able to make a break for his freedom."
McFaul said it was unclear whether the vehicles had been struck by missiles fired from helicopters or by ground forces.
The attack in Algeria did not stop France from pressing on with its campaign in Mali. It said on Thursday it now had 1,400 troops on the ground there, and combat was under way against the rebels that it first began targeting from the air last week.
"What is happening in Algeria justifies all the more the decision I made in the name of France to intervene in Mali in line with the U.N. charter," Hollande said on Thursday.
The French action last week came as a surprise but received widespread public international support. Neighbouring African countries planning to provide ground troops for a U.N. force by September have said they will move faster to deploy them.