U.S. General David Petraeus relinquished command of the war in Afghanistan on Monday to take the helm of the C.I.A., at a time of growing concern over the ability of Afghan forces to keep the Taliban in check.
After reluctantly accepting the job a year ago, the veteran commander oversaw a "surge" of 30,000 extra U.S. forces which blunted attacks of a resurgent Taliban.
Many had hoped Petraeus would be able to repeat his successes in Iraq, where he won over tribal groups and used a surge of reinforcements to turn the tables on the insurgency.
(From GlobalPost in Afghanistan: Afghanistan: A tale of two districts)
But recent spectacular attacks including the assassination of the powerful half-brother of Afghan President Hamid Karzai and a brazen raid on a luxury hotel outside Kabul have demonstrated the Taliban's resilience.
NATO said an explosion killed three of its troops Monday in the east of the country.
Chairman of the U.S. Joint Chiefs of Staff Admiral Mike Mullen, top Marine General James Mattis and NATO commander General Wolf Langheld attended the flag-changing ceremony in Kabul.
"We should be clear-eyed about the challenges that lie ahead," Petraeus said as he handed command of the NATO-led International Security Assistance Force (ISAF) to U.S. Marine Corps General John Allen, Reuters reported.
Allen said the international military campaign faced "tough days" ahead but he wanted to "maintain the momentum of the campaign," the Daily Mail reported.
"I have no illusions about the challenges ahead," he said.
The challenges were brutally underscored on Sunday when gunmen assassinated Jan Mohammad Khan, a former governor of southern Uruzgan province and senior adviser to Karzai, in his Kabul home.
The handover of command came as NATO began transitioning areas of the country to Afghan control, starting in the northern province of Bamiyan.
General Petraeus is leaving Afghanistan to take charge of the Central Intelligence Agency, where he replaces Leon Panetta, who became defense secretary.
Foreign troops which helped to oust the Taliban from power in 2001 are due to withdraw entirely from Afghanistan by 2014.