BRUSSELS — NATO leaders said Thursday that they would continue carrying out airstrikes in Libya and patrolling its coastline because of ongoing resistance from forces loyal to deposed leader Moammar Gaddafi.

NATO’s political leadership said it would end military operations in Libya “soon” but emerged from two days of meetings at the alliance’s headquarters in Belgium without making a clear decision on how to wind down the war.

Although Gaddafi remains in hiding, some U.S. and NATO officials said it would be a mistake to withdraw from Libya as long as fighting continues in Sirte and Bani Walid, two cities still under the control of pro-Gaddafi forces. Gaddafi was driven from power six weeks ago when rebels captured the capital, Tripoli.

“The time to end our mission will come soon,” Anders Fogh Rasmussen, the NATO secretary general, said at a news conference. “We stand ready to terminate it when the political and military conditions are fulfilled.”

Rasmussen said the threat to civilians from Gaddafi loyalists was “fading away,” but he was vague about how and when NATO leaders would decide to their involvement in the conflict.

NATO is still carrying out airstrikes daily even though rebel forces swept into Tripoli in late August and took control of most of the country. However, the pace of the attacks has slackened lately. NATO reported conducting 21 airstrikes Tuesday, half the number of two weeks ago.

U.S. Defense Secretary Leon E. Panetta said NATO needs a better assessment of how much Libyan civilians remain at risk before the alliance withdraws its forces. He cited street battles in Sirte as a particular concern. He also said it remains an open question whether Gaddafi is still able to give orders to loyalists in the field.

Panetta played down a report in the Los Angeles Times that NATO members were at odds over when to end the mission.

“There was a pretty clear consensus on how we move forward,” he said, without giving details.

While some NATO countries are eager to declare victory and pull out, others worry that an early withdrawal — especially with Gaddafi still at large — could encourage loyalists to rebound or launch an insurgency. Also a concern is whether Libya’s fledgling new government, comprised of various anti-Gaddafi factions, can provide effective security throughout the country.

Later Thursday, Panetta traveled to Naples, Italy, to meet with U.S. and NATO commanders who have overseen the air and naval missions in Libya. He said the decision on when to cease operations “will depend a great deal on the recommendations of our commanders.”

NATO, which has 28 members, operates by consensus, meaning that all countries must endorse any decision.

Not all NATO member countries have participated in the Libyan war. Among those that have played significant roles are Canada, France, Britain, Italy, Denmark, Norway and Belgium. Military forces from some Arab countries have also taken part.

The U.S. military led the initial wave of attacks in March that suppressed Gaddafi’s air defenses, and it continues to conduct most surveillance and refueling operations. But other NATO countries have taken over the lead responsibility for enforcing a no-fly zone over Libya and carrying out airstrikes.

NATO intervened in Libya after the U.N. Security Council authorized intervention in March to protect civilians facing reprisals from Gaddafi’s forces for supporting an uprising against his nearly 42-year rule.

U.S. Adm. James Stavridis, NATO’s supreme allied commander, said military leaders will present their advice to Panetta in Naples on Thursday and Friday. “Then that will move into the political sphere here in NATO,” he told reporters in Brussels.

French Defense Minister Gerard Longuet said NATO should continue airstrikes until all Gaddafi holdouts are silenced or until Libya’s new government asks for a cease-fire. Although most public attention has focused on the battle for Sirte, Longuet said he was concerned about fighting elsewhere as well.

“Sirte has an extremely symbolic value, but it’s not all of Libya,” Longuet told reporters. “There is pro-Gaddafi resistance in Bani Walid and dispersed resistance in the south of the country.”

In other news, Panetta rejected a suggestion from some Iraqi leaders that they would be willing to have U.S. military trainers stay in that country beyond the end of the year, but only if they are not given immunity from Iraqi prosecution.

“Any kind of a U.S. presence demands that we protect and provide the appropriate immunities for our soldiers,” Panetta told a news conference.

The U.S. military faces a Dec. 31 deadline to withdraw all troops from Iraq. But Iraqi and U.S. officials are talking about a possible deal that would keep a few thousand forces there to train the Iraqi military.

Craig Whitlock covers the Pentagon and national security. He has reported for The Washington Post since 1998.

Comments our editors find particularly useful or relevant are displayed in Top Comments, as are comments by users with these badges: . Replies to those posts appear here, as well as posts by staff writers.

To pause and restart automatic updates, click "Live" or "Paused". If paused, you'll be notified of the number of additional comments that have come in.

Comments our editors find particularly useful or relevant are displayed in Top Comments, as are comments by users with these badges: . Replies to those posts appear here, as well as posts by staff writers.