UK troops can come home from Afghanistan knowing it was mission accomplished, David Cameron has said as he visited the country.
The prime minister met forces stationed at Camp Bastion in Helmand, a year before the last British combat forces are due to leave the country.
He said a "basic level of security" had been achieved and troops could "come home with their heads held high.
But Labour warned against complacency, insisting the "job was not yet done".
Military experts said UK troops had been broadly successful in fulfilling their central objectives - set out in their UN mandate - of protecting the Afghan population and institutions from Taliban insurgents and ensuring al-Qaeda did not regain a foothold in the country.
However, senior military figures are braced for increased activity next year as more troops pull out and expect elections being staged next year to be a particular focus for insurgent groups.
Asked by reporters if personnel were coming home with the message "mission accomplished", the prime minister, accompanied by former England footballer Michael Owen, said: "Yes, I think they do."
He added: "To me, the absolute driving part of the mission is a basic level of security so it doesn't become a haven for terror. That is the mission, that was the mission and I think we will have accomplished that mission and so our troops can be very proud of what they have done."
Mr Cameron's comments come two months after Afghan president Hamid Karzai said there was only "partial" security in the country and foreign troops should have done more to target safe havens in Pakistan.
They also echo former US President George W Bush's May 2003 declaration that the US role in Iraq was "mission accomplished", only to see a big increase in sectarian violence which lasted a decade.
Asked whether Mr Cameron's own comments risked seeming premature, a No 10 spokesman said he had not used the words "mission accomplished" himself but had responded to a question from a journalist accompanying him.
He had said the situation in Afghanistan was not perfect, but the threats from terrorists had decreased and "that's because of the achievements of our armed forces".
As to whether the mission had been accomplished, BBC security correspondent Frank Gardner said the presence of UK and other foreign troops in Afghanistan since 2001 had stopped al-Qaeda cells from operating in the country.
However he said there were already signs that as US forces withdraw from some of the more remote provinces in the north-east, al-Qaeda were filtering back in, so in terms of international terror (as opposed to insurgency within the country which remains high), his verdict was "12 years successful, future uncertain".
Mr Cameron's brief visit was what has become a traditional pre-Christmas prime ministerial trip.
He took a helicopter to a forward operating base in the Nahr-e Saraj part of Helmand, where he had lunch with a small group of soldiers.
Around 5,200 British troops are now based in Afghanistan, down from 9,000 at the start of the year. There have been 446 British deaths since operations began in 2001.
Speaking afterwards to journalists Mr Cameron said: "The timetable for the withdrawal of British troops is a plan that we will stick to. I said, back in 2010, that after the end of 2014 there would not be British troops in a combat role and we will stick to that.
"We are not going to abandon this country. We are going to go on funding the Afghan National Army and police into the future.
"We will have a development programme into the future and, of course, we are providing what the president of Afghanistan asked me for, which is an officer training academy in Kabul which will help provide the backbone of the Afghan National Army for the future.
"So, we have more than played our part in helping to rebuild this country and making it safe.
"Our commitment goes on into the future but our troops have done enough and it's time for them to come home."
Peter Quentin, from the Royal United Services Institute, said that despite talk over the years of "nation building" in Afghanistan, the Ministry of Defence had always insisted the mission's over-riding focus was counter-terrorism.
Security had improved in "leaps and bounds" in recent years, he said, and no major terrorist attack had been planned from Afghanistan for more than a decade.
But he said 2014 would be a real test for the country, with presidential elections due and questions over the long-term financial support required to maintain the Afghan security forces.
Labour said the "job was not yet done" and UK troops still needed the support of the British public for their remaining time there.
"There is no room for complacency when our armed forces are engaged in an ongoing, dangerous and complicated military operation," said shadow defence secretary Vernon Coaker.
The head of Nato, Anders Fogh Rasmussen, said international forces had "achieved what we came here" for by preventing terrorists using the country as a safe haven.