On the way to Europe in October, Secretary of State Hillary Rodham Clinton made a much-publicized stop in Algeria to enlist that nation’s help in combating militants who had established a sanctuary in neighboring Mali, including fighters from Al Qaeda in the Islamic Maghreb.

But the limits of Algeria’s cooperation with the United States were visible on Thursday when Algerian forces stormed the gas facility where Islamic extremists were holding dozens of American and other foreign hostages — an operation that a Pentagon official said was undertaken without consultation with the United States.

“The Algerians are jealous of their sovereignty, and that explains why they haven’t consulted with the Americans,” said Anouar Boukhars, an expert on North Africa at the Carnegie Endowment for International Peace. “Their position is no negotiation with violent extremists.”

Obama administration officials have been reluctant to discuss the rescue mission, which Algerian officials acknowledged led to the death of some hostages. With an eye on Mali, however, American officials made clear that they planned to continue nurturing the relationship with Algeria.

“When this incident is finally over,” Mrs. Clinton said on Thursday, “we’re going to do everything we can to work together to confront and disrupt Al Qaeda in the Islamic Maghreb.”

She had talked by phone on Wednesday with Algeria’s prime minister, Abdelmalek Sellal. The call concerned “what might be needed” to deal with the hostage situation and “the desire to keep lines of communication open,” said Victoria Nuland, the State Department spokeswoman.

The State Department would not say if the United States had been notified in advance of Thursday’s operation by the Algerians, but a Pentagon official said it had not.

Some former American officials who have dealt extensively with the Algerian military said on Thursday that they were not surprised that the Algerians would stage an operation without notifying other countries, including Britain and Japan, which were among the countries whose citizens were taken hostage, but which also received no advance notice of the operation.

“This is how they operate; they like to do things unilaterally,” said Rudy Atallah, a former Air Force Special Operations officer and director of African counterterrorism for the Pentagon.

For all that, American officials were striving to keep relations with Algeria on track.

“One thing that is clear: there will not be a satisfactory solution in Mali without Algeria’s participation,” Gen. Carter F. Ham, the head of the African Command, said at a recent news conference in Niger’s capital, Niamey.

The Algerians have their own interests in a good relationship. They have concerns about deteriorating security in Mali, and the United States is the largest buyer of Algeria’s oil.

Over the last year, the position of Mr. Sellal’s government on Mali has changed. At first, Algerian officials were worried that a military campaign against militants in Mali might push them north into Algerian territory and radicalize the Tuaregs, a nomadic group in the desert area straddling the borders of Algeria, Mali and Niger.

But as security in Mali worsened, the United States and France stepped up their entreaties to the Algerians. The October visit was Mrs. Clinton’s second as secretary of state, and was followed by a November visit by William J. Burns, the deputy secretary of state, and December meetings between American and Algerian counterterrorism officials.

Algeria has made clear that it will not send troops to Mali, but it began to help in other ways, including by sending thousands of troops to the southern part of its country to secure the border.

The American and French diplomacy also appeared to pay off when, after the militants in Mali began to move south this month, Algeria responded by opening its airspace to the French as they began to rush troops to the landlocked African nation.

“That tells you how pragmatic they have become,” Mr. Boukhars said.

Still, Algeria’s cooperation has not always been everything American officials have wished.

“Senior military and civilian leaders in Algeria have a clear understanding of the threat that exists in northern Mali,” General Ham said. “That doesn’t mean we all agree on all of the details.”

General Ham, who has visited Algeria four times in the past two years, praised the Algerians for tightening their southern border “so that terrorist forces in northern Mali cannot move freely across the region.” But he gently urged the country to work harder to “communicate more clearly and more directly” with Mali and other border nations “so that they could pass information that affects their shared borders more quickly.”

Current and former American officials, along with Algeria experts, describe Algeria’s national security apparatus as something of a black box. A report last year by the Congressional Research Service said that the Algerian president, Abdelaziz Bouteflika, had consolidated his power by diminishing the influence of senior military commanders.

At the same time, according to the report, a military intelligence service, the Department of Intelligence and Security, retains vast power over government decision-making, and operates largely independently from the traditional military chain of command.

A shadowy figure, Gen. Mohamed Mediène, has run the service since the early 1990s. Algeria analysts know very little about him, and few pictures of him exist in the public realm.

In brief remarks at the State Department on Thursday, Mrs. Clinton kept her focus on Mali, avoiding any talk of Algeria’s internal security arrangements. “We’re going to be working with our friends and partners in North Africa,” she said, before speaking again by phone with Algeria’s prime minister.

Eric Schmitt contributed reporting.