ALGIERS The gas plant at In Amenas is giving up its secrets as Algerian special forces picking their way through the vast complex find dozens of bodies, some charred beyond recognition in the bloody end-game to one of the worst hostage crises in years.
Five days after 40 jihadist fighters raided the desert facility not far from the Libyan border and Algeria responded with a full-on military operation to kill or capture them, a picture of what happened is beginning to emerge.
While some of the hostages escaped in the early stages of the crisis, hopes faded for dozens of others, foreign workers and Algerians, once the army decided to take on the raiders.
Those who escaped had harrowing tales to tell. One Briton recounted how the attackers had strapped Semtex plastic explosive to his neck, bound his hands and taped his mouth shut. Another man hid for more than a day and a half under his bed as jihadist fighters searched the workers' residential complex.
Algerian sources said the attackers had come from Libya, but two of the Islamist fighters whose bodies were recovered appeared to be Canadian.
Workers from the United States, Britain, France, Japan, Romania, Norway and the Philippines were either dead of missing, with the overall death toll among hostages and militants put at 80 and rising.
The In Amenas gas plant probably felt impregnable to many who worked there - fenced in, hundreds of miles from anywhere and with the Algerian army patrolling its desert approaches.
That was a mirage. Libya, an ex-police state turned arms bazaar and now open for jihad, lies just 50 miles away. And in any case, the enemy was probably already inside the gates.
At least some the Islamist guerrillas who stormed in before dawn on Wednesday had driven along smugglers' tracks across the Libyan border just after midnight, an Algerian security official told Reuters, citing evidence from mobile phones traced to the militants.
The militants arrived in nine Toyotas with Libyan plates and painted in the colours of Sonatrach, the Algerian oil and gas company that has a share in the plant, according to the Algerian daily El Khabar.
The ease with which they entered the fortified housing compound and nearby natural gas plant left Algerians in little doubt the gunmen had allies among people at the site.
"They had local cooperation, I'm sure, maybe from drivers or security guards, who helped the terrorists get into the base," said Anis Rahmani, editor of Algeria's Ennahar newspaper and a writer on security issues who said he was briefed by officials.
Officials in this secretive country said they had discovered cases before when Islamist rebels succeeded in having fellow militants employed by international energy companies. One told Reuters it was possible insiders had cooperated at In Amenas.
Locally hired workers who escaped told Reuters of seeing the gunmen moving around the sprawling facility with confidence, apparently familiar with its layout and well prepared.
The militants said they launched the raid to halt French military intervention in neighbouring Mali, which began a week ago, however the link is not yet clear. Several European and U.S. officials said the assault seems too elaborate to have been planned in such a short time.
It is possible the attack would have happened anyway, or that the French military operation provided a trigger to carry out an attack based on preparations made earlier.
Much may never become clear. The raid was carried out in a region closed to outsiders within a country whose government is unused to sharing sensitive information with the public.
First word of trouble came crackling over a walkie-talkie to the communications room at In Amenas, where a 27-year-old radio operator called Azedine logged a contact with a bus driver who, at 5:45 a.m. (0445 GMT), left to take some foreigners to the airstrip at the town of In Amenas, some 50 km (30 miles) away.
"Moments after the bus left, I heard shooting, a lot of shooting, and then nothing," Azedine told Reuters on Friday.
Two people, one British, one Algerian were killed on two buses heading for the airport. It is not clear whether that incident was part of the plan that secured the militants access to the compound. Almost immediately after the bus skirmish, they were inside, in at least three vehicles.
The first Briton to die was identified as a Gulf war veteran who had been in the French Foreign Legion and was working for a security company.
People who have worked at the site, which sits with its back to cliffs in the dunes, say there was normally an overnight curfew, leaving it unclear how the gunmen were able to get so close before being challenged. Their initial approach may have been well off the main roads.
Freed hostages spoke of an alarm being raised, of frightened people staying in their offices or hiding in their dormitories.
Azedine saw a gunman put on the ID badge of a French supervisor who had been shot dead.
A French catering firm employee spent 40 hours cowering alone under his bed, terrified he would be killed.
Alexandre Berceaux said he had survived by staying in his room away from other foreigners, hidden behind a barricade of wooden planks and having Algerian colleagues sneak him food and water.
Pulled to safety on Thursday evening with other foreigners by Algerian soldiers who stormed the site, Berceaux had been so scared of being discovered that he only opened his bedroom door if the person knocking gave a secret password.
"I was completely isolated ... I was afraid. I could see myself already ending up in a wooden box," Berceaux said in a radio interview.
Rapidly the area was surrounded by heavily armed Algerian troops, with tanks, armoured vehicles and helicopter gunships from a nearby military base. The government in Algiers said it would not negotiate.
People who know the site, operated by Britain's BP and Statoil of Norway along with Algeria's state energy company, Sonatrach, said a barracks housing several hundred soldiers lies along the three km (two miles) of road separating the accommodation compound from the industrial plant.
A former senior Algerian government official said guards appeared to have been caught napping: "They have all kinds of equipment, detailed surveillance, cameras," he said. "They were caught maybe at the right time, at five in the morning."
But he also acknowledged the militants may have had help among the local workforce: "Out of 700 Algerians, I am sure they will find a couple who will cooperate. It always happens."
Militant leaders like Taher Ben Cheneb, said by officials to have been one of the commanders of the operation and to have been killed on Thursday, have stoked resentment among southerners at the way foreigners and northerners dominate the better paid jobs in the oil fields.
Ben Cheneb, described as a high school maths teacher in his 50s, led the Movement of the Islamic Youth in the South. Security expert Rahmani said he joined forces for this operation with followers of Mokhtar Belmokhtar, a veteran of Afghan wars and a leading figure in Al Qaeda in the Islamic Maghreb (AQIM) who recently formed a new group named Mulathameen.
Belmokhtar, the overall commander but not present during the attack, claimed responsibility on behalf of al Qaeda for a raid he called a "blessed operation".
The two men had cooperated before, Rahmani said, notably in damaging an airliner in 2007 at Djanet, further to the south.
While Ben Cheneb's group appeared to have moved on In Amenas from a base inside Algeria, Rahmani said, Belmokhtar's men, led by Abu El Bara, appeared to have come in from Libya. Ben Cheneb, however, was based in Libya and had married a Libyan woman only two months ago, according to El Khabar.
The group's field commander was a veteran fighter from Niger called Abdul Rahman al-Nigeri, Mauritanian news agencies reported. He led his men into the gas plant, where he is believed to have been killed, while another of the group's leaders, Abu al-Bara'a al-Jaza'iri, was killed at the residential complex.
Noting the one-eyed Belmokhtar's reputation as a cigarette smuggler as well as a holy warrior - locals call him the "Mister Marlboro" - Rahmani added: "They use the same back roads as the smugglers. You need a perfect knowledge of the Sahara to do it.
"They can use the same wells as the smugglers, the same fuel dumps hidden in the desert."
Canadian diplomat Robert Fowler, who was captured by Belmokhtar in Niger in 2008 and released after four months, nicknamed him "Jack" so as to be able to discuss him privately with fellow captives. Belmokhtar in turn referred to his prisoners as apostates and infidels.
More than a decade after Algeria's civil war killed some 200,000 people, Islamist fighters roam the sandy wastes of Africa's biggest country, mixing smuggling and kidnapping for ransom with opposition to the political establishment that has ruled in Algiers since French colonists left half a century ago.
These groups have been energised by the return of heavily armed ethnic Tuaregs and others from Libya, where they fought as mercenaries for Muammar Gaddafi until his overthrow in 2011. The new Libyan authorities are struggling to control their own deep south and it provides a launchpad for raids across the frontier.
While security forces seek to impose control, the tracts of sand are vast, borders among the half dozen countries around the desert are unmarked, and the big money that can be made from illicit trade or kidnapping tourists and Western engineers can be used to buy favours from ill-paid officials.
Al Qaeda says it is fighting for a Muslim caliphate that transcends artificial borders in the Maghreb set by colonial powers.
Once inside the facility, militants, including bearded, ragged fighters and others in more urban dress, herded groups of Westerners together. Hundreds of Algerians were guarded more loosely. One Algerian worker told Reuters the gunmen said they were only interested in killing "Christians and infidels".
Several former hostages described the attackers, from their accents, as appearing to be Libyan or Egyptian as well as Algerian. Officials said many of the dead gunmen were foreign.
Algeria told Western governments, which voiced dismay at the storming of the facility on Thursday, that troops moved in only because guerrillas were trying to leave with hostages, possibly hoping to reach the Malian border.
The captors loaded hostages into a convoy. Special forces backed by helicopters moved in around noon, some 30 hours after the plant was seized.
In what appears to have been the deadliest part of the siege, as described by the family of Irish survivor Stephen McFaul, government forces bombed the convoy, blasting apart four vehicles full of hostages. McFaul was in a fifth truck which crashed. He dashed for his life and escaped, and believes all those in the other vehicles were killed.
McFaul told how the attackers had turned him into a human bomb, strapping Semtex round his neck.
Another Briton, Garry Barlow, called his wife from within the site during the attack and said: "I'm sat here at my desk with Semtex strapped to my chest."
During Thursday, most of the hundreds of people at the site were able to flee, some of them Westerners posing as Algerians.
"We cut the wire with clippers and ran for it, all together, about 50 of us with the three foreigners," one man was quoted as saying by The Times.
By Friday night, it remained unclear how many of the gunmen and their hostages were still in the facility - though both groups might number in the dozens.
The operation at the larger, residential compound was over and troops were now surrounding the industrial site, where Nigeri and his men were reported to be holding a group of hostages.
But this left Western governments and intelligence officials, long used to difficult relations with Algeria which is proud of its sovereignty, desperate for hard facts about the fate of their nationals.
Western capitals seemed to be in the dark when the dramatic and bloody final assault came on Saturday morning.
Algerian soldiers shot dead 11 gunmen who had executed seven foreign hostages, according to the state news agency. The militants were then found to have booby-trapped the gas complex with explosives, which the army had to defuse.
The operation appeared to be over, but mopping up went on for many hours, with dozens more bodies still being found and many questions still to be answered.
(Additional reporting by Alex Lawler and Jessica Donati in London, Writing by Alastair Macdonald; editing by Giles Elgood and Peter Millership)