Fast-moving details of the military operation to free the hostages were difficult to confirm. Algeria's official APS news agency said that the military had freed four foreign hostages, giving no further information.
A local source told Reuters six foreign hostages were killed along with eight captors when the Algerian military fired on a vehicle being used by the gunmen. An Algerian security source said the 25 foreign hostages had escaped.
Mauritania's ANI news agency, which has been in constant contact with the kidnappers, said seven hostages were still being held: two Americans, three Belgians, one Japanese and one British citizen.
The standoff began when gunmen calling themselves the Battalion of Blood stormed the gas plant on Wednesday morning. They said they were holding 41 foreigners and demanded a halt to a French military operation against fellow al-Qaida-linked Islamist militants in neighbouring Mali.
ANI and Qatar-based Al Jazeera reported that 34 of the captives and 15 of their captors had been killed when government forces fired from helicopters at a vehicle. Those death tolls, far higher than confirmed by the local source, would contradict the reports that large numbers of foreigners escaped alive.
Britain and Norway, whose oil firms BP and Statoil run the plant jointly with the Algerian state oil company, said they had been informed by the Algerian authorities that a military operation was under way but did not provide details.
As many as 180 Algerian hostages had also been held but managed to flee, the local source said.
The incident dramatically raises the stakes in the French military campaign in neighbouring Mali, where hundreds of French paratroopers and marines are launching a ground offensive against rebels after air strikes began last week.
Algerian Interior Minister Daho Ould Kablia said the kidnappers were led by Mokhtar Belmokhtar, a veteran Islamist guerrilla who fought Soviet forces in Afghanistan in the 1980s and had set up his own group in the Sahara after falling out with other local al Qaeda leaders.
A holy warrior-cum-smuggler dubbed "The Uncatchable'' by French intelligence and "Mister Marlboro'' by some locals for his illicit cigarette-running business, Belmokhtar's links to those who seized towns across northern Mali last year are unclear.
The hostage takers earlier allowed some prisoners to speak to the media, apparently to put pressure on Algerian forces not to storm the compound. An unidentified hostage who spoke to France 24 television said prisoners were forced to wear explosive belts and captors had threatened to blow up the plant.
Two hostages, identified as British and Irish, spoke to Al Jazeera television and called on the Algerian army to withdraw from the area to avoid casualties.
"We are receiving care and good treatment from the kidnappers. The [Algerian] army did not withdraw and they are firing at the camp,'' the British man said. ``There are around 150 Algerian hostages. We say to everybody that negotiations is a sign of strength and will spare many any loss of life.''
The precise number and nationalities of foreign hostages could not be confirmed, with some countries reluctant to release information that could be useful to the captors.
Britain said one of its citizens was killed in the initial storming on Wednesday and ``a number'' of others were held.
The militants said seven Americans were among their hostages, a figure U.S. officials said they could not confirm.
Norwegian oil company Statoil said nine of its Norwegian staff and three Algerian employees were captive. Britain's BP, which operates the plant with Statoil and Algerian state oil company Sonatrach, said some of its staff were held but would not say how many or their nationalities.
Japanese media said five workers from Japanese engineering firm JGC Corp. were held, a number the company did not confirm. Paris has not said whether any hostages were French. Vienna said one hostage was Austrian, Dublin said one was Irish and Bucharest said an unspecified number were Romanian.
Spanish oil company Cepsa said it had begun to evacuate personnel from elsewhere in Algeria.
Paris said the Algeria attack demonstrated it was right to intervene in Mali: "We have the flagrant proof that this problem goes beyond just the north of Mali,'' French ambassador to Mali Christian Rouyer told France Inter radio.
President Francois Hollande has received public backing from Western and African allies who fear that al Qaeda, flush with men and arms from the defeated forces of Libya's Muammar Gaddafi, is building a desert haven in Mali, a poor country helpless to combat fighters who seized its north last year.
However, there is also some concern in Washington and other capitals that the French action in Mali could provoke a backlash worse than the initial threat by militants in the remote Sahara.
The militants, communicating through established contacts with media in neighboring Mauritania, said they had dozens of men armed with mortars and anti-aircraft missiles in the compound and had rigged it with explosives.
"We hold the Algerian government and the French government and the countries of the hostages fully responsible if our demands are not met, and it is up to them to stop the brutal aggression against our people in Mali,'' read one statement carried by Mauritanian media.
They condemned Algeria's secularist government for letting French warplanes fly over its territory to Mali and shutting its border to Malian refugees.
Mali campaign presses on
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 in Mali, and combat was underway against the rebels that it first began targeting from the air last week.
"There was combat yesterday, on the ground and in the air. It happened overnight and is under way now,'' said Le Drian. Residents said a column of about 30 French Sagaie armoured vehicles set off on Wednesday toward rebel positions from the town of Niono, 300 km (190 miles) from the capital, Bamako.
The French action last week came as a surprise but received widespread international support in public. Neighboring African countries planning to provide ground troops for a U.N. force by September have said they will move faster to deploy them.
Nigeria, the strongest regional power, sent 162 soldiers on Thursday, the first of an anticipated 906.
"The whole world clearly needs to unite and do much more than is presently being done to contain terrorism, with its very negative impact on global peace and security,'' President Goodluck Jonathan said.
Germany, Britain and the Netherlands have offered transport aircraft to help ferry in African troops. Washington has said it is considering what support it can offer.
Many inhabitants of northern Mali have welcomed the French action, though some also fear being caught in the cross-fire. The Mali rebels who seized Timbuktu and other oasis towns in northern Mali last year imposed Islamic law, including public amputations and beheadings that angered many locals.
A day after launching the campaign in Mali, Hollande also ordered a failed rescue in Somalia on Saturday to free a French hostage held by al-Qaida-linked al Shabaab militants since 2009. Al Shabaab said on Thursday it had executed hostage Denis Allex. France said it believed he died in the rescue.