* Algerian PM: 38 dead civilians, 29 militants killed
* Dead Canadian named as "Chedad" coordinated attack -PM
* Of hostages, 37 foreigners killed; five more still missing
* Three Islamist assailants taken into custody
* Japanese, Filipinos, British, Norwegians among the dead
By Lamine Chikhi
ALGIERS, Jan 21 (Reuters) - A total of 37 foreigners and an Algerian died at a desert gas plant and five are still missing after a four-day hostage-taking coordinated by a Canadian gunman, Algerian Prime Minister Abdelmalek Sellal said on Monday.
Sellal also told a news conference that 29 Islamists had been killed in the siege, which Algerian forces ended by storming the plant on Saturday, and three were taken alive. Most of the gunmen were from various states of north and west Africa.
With some bodies burned beyond recognition and Algerian forces still combing the sprawling site, some details were still unclear or at odds with figures from other governments.
The siege has shaken confidence in the security of Algeria's vital energy industry and drawn attention to Islamist militancy across the Sahara, where France has sent troops to neighbouring Mali to fight rebels who have obtained weaponry from Libya.
Of the 38 dead captives, out of a total workforce of some 800 at the In Amenas gas facility, seven were still unidentified but assumed to be foreigners, Algerian premier Sellal said.
Citizens of nine countries died, he said, among them seven Japanese, six Filipinos, two Romanians, an American, a Frenchman and four Britons. Britain said three Britons were dead and three plus a London-based Colombian were missing and believed dead.
Norway said the fate of five of its citizens was unclear; in addition to seven Japanese dead, Tokyo said three were missing.
An Algerian security source had earlier told Reuters that documents found on the bodies of two militants had identified them as Canadians: "A Canadian was among the militants. He was coordinating the attack," Sellal said, adding that the raiders had threatened to blow up the gas installation.
That Canadian's name was given only as Chedad. Algerian officials have also named other militants in recent days as having leadership roles among the attackers. Veteran Islamist Mokhtar Belmokhtar claimed responsibility on behalf of al Qaeda.
In Ottawa, Canada's foreign affairs department said it was seeking information, but referred to the possible involvement of only one Canadian.
The jihadists had planned the attack two months ago in neighbouring Mali, Sellal added. During the siege, from which he said they had hoped to take foreign hostages to Mali, the kidnappers had demanded France end its military operation.
Sellal said that initially the raiders in Algeria had tried to hijack a bus carrying foreign workers to a nearby airport and take them hostage. "They started firing at the bus and received a severe response from the soldiers guarding the bus," he said. "They failed to achieve their objective, which was to kidnap foreign workers from the bus."
He said special forces and army units were deployed against the militants, who had planted explosives in the gas plant with a view to blowing up the facility. Normally producing 10 percent of Algeria's natural gas, it was shut down during the incident.
The government now aims to reopen it this week.
One group of militants had tried to escape in some vehicles, each of which also was carrying three or four foreign workers, some of whom had explosives attached to their bodies.
After what he called a "fierce response from the armed forces", the raiders' vehicles crashed or exploded and one of their leaders was among those killed.
LIBYAN NUMBER PLATES
Sellal said the jihadists who staged the attack last Wednesday had crossed into the country from neighbouring Libya, after arriving there from Islamist-held northern Mali via Niger.
An Algerian newspaper said they had arrived in cars painted in the colours of state energy company Sonatrach but registered in Libya, a country awash with arms since Western powers backed a revolt to bring down Muammar Gaddafi in 2011.
The raid has exposed the vulnerability of multinational-run oil and gas installations in an important producing region and pushed the growing threat from Islamist militant groups in the Sahara to a prominent position in the West's security agenda.
Algerian President Abdelaziz Bouteflika has ordered an investigation into how security forces failed to prevent the attack, the daily El Khabar said.
Algerian Tahar Ben Cheneb - leader of a group called the Movement of Islamic Youth in the South who was killed on the first day of the assault - had been based in Libya where he married a local woman two months ago, it said.
Belmokhtar - a one-eyed jihadist who fought in Afghanistan and Algeria's civil war of the 1990s when the secular government fought Islamists - tied the desert attack to France's intervention across the Sahara against Islamist rebels in Mali.
"We in al Qaeda announce this blessed operation," he said in a video, according to Sahara Media, a regional website. About 40 attackers participated in the raid, he said, roughly matching the government's figures for fighters killed and captured.
Belmokhtar demanded an end to French air strikes against Islamist fighters in neighbouring Mali. These began five days before the fighters swooped before dawn and seized a plant that produces 10 percent of Algeria's natural gas exports.
U.S. and European officials doubt such a complex raid could have been organised quickly enough to have been conceived as a direct response to the French military intervention. However, the French action could have triggered an operation that had already been planned.
The group behind the raid, the Mulathameen Brigade, threatened to carry out more such attacks if Western powers did not end what it called an assault on Muslims in Mali, according to the SITE service, which monitors militant statements.
In a statement published by the Mauritania-based Nouakchott News Agency, the hostage takers said they had offered talks about freeing the captives, but the Algerian authorities had been determined to use military force. Sellal blamed the raiders for the collapse of negotiations.
The siege turned bloody on Thursday when the Algerian army opened fire, saying fighters were trying to escape with their prisoners. Survivors said Algerian forces blasted several trucks in a convoy carrying both hostages and their captors.
Nearly 700 Algerian workers and more than 100 foreigners escaped, mainly on Thursday when the fighters were driven from the residential barracks. Some captors remained holed up in the industrial complex until Saturday when they were overrun.
The bloodshed has strained Algeria's relations with its Western allies, some of which have complained about being left in the dark while the decision to storm the compound was being taken.
Nevertheless, Britain and France both defended the military action by Algeria, the strongest military power in the Sahara and an ally the West needs in combating the militants.
"This would have been a most demanding task for security forces anywhere in the world and we should acknowledge the resolve shown by the Algerians in undertaking it," British Prime Minister David Cameron told parliament on Monday.
The raid on the plant, which was home to expatriate workers from Britain's BP, Norway's Statoil, Japanese engineering firm BGC Corp and others, exposed the vulnerability of multinational oil operations in the Sahara.
However, Algeria is determined to press on with its energy industry. Oil Minister Youcef Yousfi visited the site and said physical damage was minor, state news service APSE reported. The plant would start up again in two days, he said.
Algeria, scarred by the civil war with Islamist insurgents in the 1990s which claimed 200,000 lives, insisted from the start of the crisis there would be no negotiation in the face of terrorism. France especially needs close cooperation from Algeria to crush Islamist rebels in northern Mali.
In a reference to Western concerns that the Sahara and the dry grasslands of the Sahel to its south may become a haven for its Islamist enemies as Afghanistan was under the Taliban before 2001, Sellal said Algeria would not become "Sahelistan".
Cameron said Islamist threats to Britain from Afghanistan and Pakistan had diminished, compared with four years ago: "But at the same time," he said, "Al Qaeda franchises have grown in Yemen, Somalia and parts of North Africa."