ALGIERS, Algeria – In a desert standoff deep in the Sahara, the Algerian army ringed a natural gas complex where Islamist militants hunkered down with dozens of hostages Wednesday night after a rare attack that appeared to be the first violent shock wave from the French intervention in Mali.

A militant group that claimed responsibility said 41 foreigners, including seven Americans, were being held after the assault on one of oil-rich Algeria’s energy facilities, 800 miles from the capital of Algiers and 1,000 miles from the coast. Two foreigners were killed.

The group claiming responsibility said the attack was in revenge for Algeria’s support of France’s military operation against al-Qaida-linked rebels in neighboring Mali. The U.S. defense secretary called it a “terrorist act.”

The militants appeared to have no escape, with troops surrounding the complex and army helicopters clattering overhead.

The group — called Katibat Moulathamine, or the Masked Brigade — telephoned a Mauritanian news outlet to say one of its affiliates had carried out the operation at the Ain Amenas gas field, and that France should end its intervention in Mali to ensure the safety of the hostages.

BP, the Norwegian company Statoil and the Algerian state oil company Sonatrach operate the gas field. A Japanese company, JGC Corp, provides services for the facility as well.

In Rome, U.S. Defense Secretary Leon Panetta declared that the U.S. “will take all necessary and proper steps” to deal with the attack in Algeria. He would not detail what such steps might be but condemned the action as “terrorist attack” and likened it to al-Qaida activities in Pakistan, Afghanistan and in the United States on Sept. 11, 2001.

Algeria’s top security official, Interior Minister Daho Ould Kabila, said “security forces have surrounded the area and cornered the terrorists, who are in one wing of the complex’s living quarters.”

He said one Briton and one Algerian were killed in the attack, and a Norwegian and two other Britons were among the six wounded.

“We reject all negotiations with the group, which is holding some 20 hostages from several nationalities,” Kabila said on national television, raising the specter of a possible armed assault to try to free the hostages.

The Norwegian newspaper Bergens Tidende said a 55-year-old Norwegian working on the site called his wife to say he had been abducted.

Algeria had long warned against any military intervention against the rebels in northern Mali, fearing the violence could spill over its own long and porous border. Though its position softened slightly after Hollande visited Algiers in December, Algerian authorities remain skeptical about the operation and worried about its consequences on the region.

Algeria, Africa’s biggest country, has been an ally of the U.S. and France in fighting terrorism for years. But its relationship with France has been fraught with lingering resentment over colonialism and the bloody war for independence that left Algeria a free country 50 years ago.

Algeria’s strong security forces have struggled for years against Islamist extremists, and have in recent years managed to nearly snuff out violence by al-Qaida in the Islamic Maghreb around its home base in northern Algeria. In the meantime, the group moved its focus southward.