Pleased by the outcome of the war in Libya, the Obama administration is suddenly all smiles among its NATO allies.

Four months after then-Defense Secretary Robert M. Gates delivered a blistering speech accusing NATO of abdicating its defense responsibilities to the United States, his successor, Leon E. Panetta, was conciliatory Wednesday in a visit to the military alliance’s headquarters in Belgium.

Before his meetings with NATO defense ministers, Panetta praised the alliance for its performance in Libya, a turnaround from the early days of the operation when U.S. officials complained that some European partners were eager to intervene in Libya — as long as they didn’t have to take charge.

“This was a mission where we saw greater leadership from our European allies,” Panetta said in a speech to the Carnegie Endowment for International Peace in Brussels. “The alliance achieved more burden-sharing between the U.S. and Europe than we have in the past, particularly for an operation conducted off of Europe’s shores, and on a mission that was in the vital interest of our European allies.”

With Libya’s longtime ruler, Moammar Gaddafi, in hiding and the new government in control of all but a few pockets of the country, NATO officials were in a self-congratulatory mood as they debated potential timelines for ending military operations in North Africa.

Last month, the alliance authorized an extension of the campaign through December. But officials said Wednesday that they hoped to wrap up operations long before that; defense leaders from NATO member countries are to meet Thursday to discuss options for ending the mission.

Although Gaddafi’s whereabouts remain uncertain, NATO Secretary General Anders Fogh Rasmussen said the ousted leader’s fate would have no bearing on the alliance’s decision on when to halt its airstrikes and patrols over Libya.

“The termination of operations is not dependent on Col. Gaddafi,” Rasmussen told a news conference. “He’s not the target of our operations.”

NATO and other allies have been operating under a U.N. Security Council mandate to protect Libyan civilians since rebels rose up against Gaddafi’s government in March.

On Tuesday, during a visit to Cairo, Panetta said NATO would probably continue patrolling Libyan skies until all Gaddafi loyalists lay down their arms. “As long as there’s fighting that’s continuing in Libya, I suspect that the NATO machine will continue, as well,” Panetta said.

In his speech in Brussels, Panetta chided NATO members for not spending more on defense over the past decade, saying that the trend raised “the risk of a weak and divided Europe.” He also echoed Gates’s complaints that European countries were content to let the United States shoulder too much of their defense burden.

But with the Obama administration facing its own growing pressures to cut defense spending, Panetta took a gentler tone than his predecessor. He also voiced more optimism about NATO’s future than did Gates, who pronounced the outlook “dim, if not dismal.”

“Our nations are grappling with significant budget challenges, putting new pressure on defense spending that has already been in decline here on the continent,” Panetta said. “But that cannot be an excuse for walking away from our national security responsibilities.”