NATO has held a ceremony in Kabul formally ending its war in Afghanistan, officials said, after 13 years of conflict and gradual troop withdrawals that have left the country in the grip of worsening conflicts with armed groups.

The event was carried out on Sunday in secret due to the threat of Taliban strikes in the Afghan capital, which has been hit by repeated suicide bombings and gun attacks over recent years.

On January 1, the US-led International Security Assistance Force (ISAF) combat mission will be replaced by a NATO "training and support" mission.

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

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

The closing of NATO's combat mission comes at the end of the country's deadliest year during the war, which saw at least 4,600 Afghan soldiers and police killed and many other civilian deaths.



About 12,500 foreign troops staying in Afghanistan will not be involved in direct fighting, but will assist the Afghan army and police in the battle against the Taliban, who ruled from 1996 until 2001.

When numbers peaked in 2011, about 130,000 troops from 50 nations were part of the NATO military alliance.

'Milestone for US'

Obama called the ceremony "a milestone for our country."

"Now, thanks to the extraordinary sacrifices of our men and women in uniform, our combat mission in Afghanistan is ending, and the longest war in American history is coming to a responsible conclusion," he said in a statement.

Obama thanked the troops and intelligence workers who served in Afghanistan, crediting them with "devastating the core al-Qaeda leadership, delivering justice to Osama bin Laden, disrupting terrorist plots and saving countless American lives".

"We are safer, and our nation is more secure, because of their service."

But, Obama warned, "Afghanistan remains a dangerous place, and the Afghan people and their security forces continue to make tremendous sacrifices in defence of their country."

Sunday's ceremony completes the gradual handover of responsibility to the 350,000-strong Afghan forces, who have been in charge of nationwide security since the middle of last year.

Al Jazeera's Jennifer Glasse, reporting from Kabul, said that Afghans were very concerned with the complete pullout, citing a security vacuum and political instability as the main threats as heavy fighting rages across the country.

"The government has also failed to name a cabinet, so it is not just the lack of security that is a concern, but also political instability".

Notes from the field: Al Jazeera's Jennifer Glasse reports from Kabul

There was a lot of mingling before the ceremony among Afghan officials, military officers, ambassadors, and diplomats from more than a dozen countries. It was a gathering befitting NATO’s largest and longest ever coalition.

In the blue and white gymnasium on ISAF’s main headquarters, a small brass military band played in the corner as US General Joseph Campbell rolled up the green flag emblazoned with ISAF for the International Security Assistance Force, he has commanded since August.

He unfurled a green flag with RS on it – the new colours as the military call them, of the NATO Resolute Support force that takes over on January 1.

The changeover marks the end of the 13-year long NATO combat mission. But about 5,500 US forces will remain in Afghanistan outside the NATO mission, carrying out counterterrorism operations.

In total, that puts about 17,000 international troops in Afghanistan in 2015.

The head of the Afghan Army, General Sher Mohammad Karimi says his forces will miss ISAF, and all the resources NATO offered. "ISAF had everything," he told me. "We are limited. We do not have enough equipment to get rid of the IEDs [improvised explosive devices, or roadside bombs] or equipment to give us early warning, but still we are doing better."

But Afghan forces continue to take punishing losses with more than 4,600 killed this year, and thousands more wounded.

The speeches acknowledged the sacrifices made. Afghanistan's National Security Adviser Mohammad Hanif Atmar said, "We will never forget your sons and daughters who have died on our soil. They are now our sons and daughters. Afghan and Coalition personnel have spilled their blood to ensure a brighter future for our country and to bring peace to the world."

No one here thinks peace will be easy. After 13 years and more than a trillion dollars spent in military and humanitarian support, Afghanistan is still in a perilous position.

It's heavily dependent on foreign aid, and the Taliban and other groups that oppose the government continue to battle Afghan forces on a number of fronts.

The mood at the transition ceremony was one of deep camaraderie between allies who have come a long way, but recognise there is still a long way to go. Not necessarily a mission accomplished – more a mission continued.