Prime Minister Tony Blair has told British troops in southern Afghanistan they are fighting for the future of the world's security.
He thanked about 800 British servicemen and women at Camp Bastion in Helmand province for the job they were doing.
"Here in this extraordinary piece of desert is where the future of world security in the early 21st Century is going to be played out," he said.
Later, he flew to Kabul to meet Afghanistan's President Hamid Karzai.
In his flying visit to the UK's main base, Mr Blair spoke of the pride and respect the country had for the work they were doing.
"We know the only way to secure peace sometimes is to be prepared to fight for it," he said.
"You're the people that are doing the difficult work. And, you should know not just you're appreciated, but the importance of the work you do is appreciated as well."
Sgt Chris Hunter, 31, from Swansea, told the prime minister: "The lads, we all want to be here.
"It is a point that is often missed back at home that the lads are proud to be here and proud to be doing our job."
Following the 90-minute visit, Mr Blair flew on to the capital Kabul where he met Lt Gen David Richards, the British officer commanding the Nato force.
BBC political editor Nick Robinson said Gen Richards had been expected to say it was necessary to sort out security in the country in the next few months if they were to retain the support of the Afghan people.
Mr Blair has not visited the 6,000-strong British force since soon after the US-led invasion in 2002.
Their fight against the Taleban is the fiercest involving British troops since the Korean War, according to Gen Richards.
So far this year, 38 British troops have been killed in Afghanistan.
On Sunday, Mr Blair was in Pakistan where he and President Pervez Musharraf agreed to strengthen their ties to fight terrorism.
They agreed restoring order in Afghanistan was crucial, and the prime minister praised Pakistan's co-operation. The president said his country was doing all it could to help.