A senior Algerian official said the militants, who claimed to have come from Mali, had used three unmarked trucks to breach the gas-field compound, outside the town of In Amenas. An oil company official who had knowledge of the attack said the militants had shut down production at the site, an indication of carefully planning. But how and why they chose In Amenas, which is more than 700 miles from the Malian border and is much closer to Libya, were among the unknowns.

The facility is the fourth-largest gas development in Algeria, a major oil producer and OPEC member. The In Amenas gas compression plant is operated by BP of Britain, the Norwegian company Statoil and the Algerian national oil company Sonatrach.

Bard Glad Pedersen, a Statoil spokesman, said that of 17 Statoil employees who had been working in the field, four escaped to a nearby Algerian military camp, but he would not say how. The Sahara Media Agency of Mauritania, quoting what it described as a spokesman for the militants, said that they were holding five hostages in a production facility on the site and 36 others in a housing area, and that there were as many as 400 Algerian soldiers surrounding the operation. But that information could not be confirmed.

Islamist groups and bandits have long operated in the deserts of western and northern Africa, and a collection of Islamists have occupied the vast expanse of northern Mali since a government crisis in that country last March. Those groups, including Al Qaeda in the Islamic Maghreb, had pledged to strike against France’s interests on the continent and abroad, as well as those of nations backing the French operations. In France, security has been reinforced at airports, train stations and other public spaces.

The militant groups are financed in large part through ransoms paid for the freeing of Western hostages, and regular kidnappings have occurred in the West African desert in recent years. At least seven French citizens are presently being held there, officials say.

Oil and gas are central to the Algerian economy, accounting for more than a third of the country’s gross domestic product, over 95 percent of its export earnings and 60 percent of government financial receipts. Algeria is an important gas supplier to France, Spain, Turkey, Italy and Britain.

Algeria has also historically been known as a relatively secure place for foreign companies to work and invest. Sonatrach and the security forces had put tight security around oil and gas facilities during the struggle with Islamic militants in the 1990s, when energy infrastructure was never a major insurgent target.