Gen. David H. Petraeus turned over command of U.S. and NATO troops in Afghanistan on Monday to Marine Gen. John Allen, as the United States and its allies begin to withdraw troops from the country where they have waged war for nearly a decade.

Petraeus ends his tour in Afghanistan without conclusive signs that the counter-insurgency strategy he helped design has turned the tide in the war against the Taliban. The more than 140,000 NATO troops under his command have weakened the insurgency in some of its key strongholds in the south, but other parts of the country remain dangerous, and Taliban leaders still operate with relative impunity from Pakistan.

On Monday morning, three NATO troops were killed in a bombing in eastern Afghanistan. And the Taliban claimed responsibility for killing a senior adviser to Afghan President Hamid Karzai and a member of parliament in Kabul on Sunday night.

The Afghan government, meanwhile, has failed to deliver meaningful services into much of the countryside or reduce the corruption that has disillusioned the Afghan people and forced repeated confrontations with its coalition partners.

In a morning ceremony outside Petraeus’s Kabul headquarters, however, the military commanders and Afghan officials emphasized positive developments from the past year, when Petraeus has been in charge.

Petraeus, who will return to Washington as director of the Central Intelligence Agency, said that coalition forces have wrested momentum from the insurgents in much of Afghanistan and have taken away Taliban sanctuaries in Kandahar and Helmand.

And with the number of Afghan and coalition forces in the country up by about 80,000, the number of attacks on coalition troops declined in May, June and the first half of July, compared with the same period in 2010 — “contrary to the forecasts of significant further increases in insurgent attack levels this year,” Petraeus said.

Allen, who had been deputy commander at U.S. Central Command in Tampa, said that he would not ease the intensity of the coalition offensive, even as U.S. and other foreign troops begin to leave and Afghans take over security responsibility in several provinces.

“It is my intention to maintain the momentum of the campaign,” Allen said.

The Afghan defense minister, Abdul Rahim Wardak, took a swipe at those pushing for a faster withdrawal and an end to the long and costly U.S. commitment to Afghanistan.

He said that once in Washington, Petraeus’s “broad intellect, his unmatched experiences and knowledge of the ground realities will make him a counterbalance to all those short-sighted, politically inspired isolationists and the groups of Beltway bandits.

“We have to assure our joint enemies that the will of the international community and the Afghan people remain unbroken,” Wardak said. “Any wavering of the resolve or premature drawdown and exit strategy will put in jeopardy all that we have achieved with so much sacrifices.”

The senior U.S. military officials in at the ceremony, including Chairman of the Joint Chiefs of Staff Adm. Mike Mullen, praised Petraeus for 37 years of military service.

Mullen called Petraeus “one of the most successful and storied generals of our time.”

“Dave has set the standard for wartime command in the modern era,” Mullen said. “There is no one, no one, in the pantheon of American military leadership who so perfectly symbolizes the scope of the effort of our armed forces.”