KABUL, Afghanistan - The United States and NATO formally ended their war in Afghanistan on Sunday with a ceremony at their military headquarters in Kabul as the insurgency they fought for 13 years remains as ferocious and deadly as at any time since the 2001 invasion that unseated the Taliban regime following the Sept. 11 attacks.

The symbolic ceremony marked the end of the U.S.-led International Security Assistance Force, which will transition to a supporting role with 13,500 soldiers, most of them American, starting Jan. 1.

Gen. John Campbell, commander of ISAF, rolled up and sheathed the green and white ISAF flag and unfurled the flag of the new international mission, called Resolute Support.

"Resolute Support will serve as the bedrock of an enduring partnership" between NATO and Afghanistan, Campbell told an audience of Afghan and international military officers and officials, as well as diplomats and journalists.

Get Breaking News Delivered to Your Inbox

He paid tribute to the international and Afghan troops who have died fighting the insurgency, saying: "The road before us remains challenging but we will triumph."

From Jan. 1, the new mission will provide training and support for Afghanistan's military, with the U.S. accounting for almost 11,000 members of the residual force.

"On this day we give thanks to our troops and intelligence personnel who have been relentless against the terrorists responsible for 9/11 -- devastating the core al Qaeda leadership, delivering justice to Osama bin Laden, disrupting terrorist plots and saving countless American lives," President Obama said in a written statement. "We are safer, and our nation is more secure, because of their service."

He also pledged to care for wounded warriors who are returning home and to stand with the families of the more than 2,200 Americans who died serving in Afghanistan.

President Ashraf Ghani, who took office in September, signed bilateral security agreements with Washington and NATO allowing the enduring military presence. The move has led to a spike in violence as the Taliban have claimed it as an excuse to step up operations aimed at destabilizing his government.

ISAF was set up after the U.S.-led invasion as an umbrella for the coalition of around 50 nations that provided troops and took responsibility for security across the country.

It ends with 2,224 American soldiers killed, according to an AP tally, out of a total of some 3,500 foreign troop deaths.

The mission peaked at 140,000 troops in 2010 with a surge ordered by U.S. President Barack Obama to root the insurgents out of strategically important regions, notably in the southern provinces of Helmand and Kandahar, where the Taliban had its capital from 1996 to 2001.

Obama recently expanded the remit of the U.S. forces remaining in the country, allowing them to extend their counter-terrorism operations to Taliban, as well as al Qaeda, and to provide ground and air support for the Afghan forces when necessary for at least the next two years.

CBS News White House correspondent Chip Reid reported that on Christmas Day, Obama visited Marine Corps Base Hawaii to deliver his thanks in person.

"The greatest Christmas present we have is the finest military the world has ever known," Obama said.

Afghans have mixed feelings about the drawdown of foreign troops, many believing that with the deteriorating security situation their presence is needed to back up the Afghan effort to bring peace after more than three decades of continual war.

"At least in the past 13 years we have seen improvements in our way of life - freedom of speech, democracy, the people generally better off financially," said 42-year-old shop keeper Gul Mohammad.

"But we do need the foreign troops to stay here at least until our own forces are strong enough, while our economy strengthens, while our leaders try to form a government," he said.

As Afghan forces assume sovereignty, the country is without a Cabinet three months after Ghani's inauguration, and economic growth is near zero due to the reduction of the international military and aid juggernauts. The United States spent more than $100 million on reconstruction in Afghanistan, on top of the $1 trillion war.

This year is set to be the deadliest of the war, according to the United Nations, which expects civilian casualties to hit 10,000 for the first time since the agency began keeping records in 2008. It says that most of the deaths and injuries are caused by Taliban attacks.

In the latest insurgent violence in eastern Wardak province, two teenage boys were killed late on Saturday, when a rocket was fired near a children's volleyball match in Nirkh district, an official said. Another five children, aged between 11 and 14 years old, were wounded by shrapnel, said the governor's spokesman Attaullah Khogyani. He blamed the Taliban.

In Kapisa, also in the east, Governor Abdul Saboor Wafa's office said eight insurgents were killed on Saturday night in an army counter-insurgency operation.

This has also been a deadly year for Afghanistan's security forces - army, paramilitary and police - with around 5,000 deaths recorded so far. Most of those deaths, or around 3,200, have been policemen, according to Karl Ake Roghe, the outgoing head of EUPOL, the European Union Police Mission in Afghanistan, which funds and trains a police force of 157,000.

NATO's Secretary General Jens Stoltenberg has said that Afghanistan's 350,000-strong security forces are ready to take on the insurgency alone, despite complaints by officials that they lack the necessary assets, such as air support, medical evacuation and intelligence.

Roghe said that while the Taliban have stretched their presence, the methodology has not changed, indicating a lack of insurgent military capacity despite the rise in attacks.

"They make a lot of damage, they send gunmen and suicide bombers to blow up the front wall and then they are immediately killed, so they achieve nothing," he said.