Tony Blair went on to meet Hamid Karzai, Afghanistan's president, in the capital, Kabul, later on Monday.
Blair told the 800 soldiers at Camp Bastion, in the south of Afghanistan: "Here, in this extraordinary desert, is where the future of world security in the early 21st century is going to be played out."
Britain has over 5,000 soldiers in Afghanistan, where fighting against the Taliban this year has been the fiercest since Kabul fell in 2002.
David Richards, a British general and the head of the Nato-led International Security Assistance Force, has said the British are facing their bloodiest fighting since the Korean war.
Blair flew to Afghanistan from Pakistan, where he had held discussions with Pervez Musharraf, Pakistan's president. The leaders had discussed the Taliban, the pooling of their counter-intelligence resources and militancy in some of Pakistan's religious schools.
After his meeting with President Karzai, Blair returned to Pakistan.
Blair told a joint news conference: "Now is the right time to bring into sharp focus the need to stay with Afghanistan in its move towards progress and redevelopment, to relive the vision that brought us here and should keep us here till the job is done."
Support grows for Taliban
With a resurgence in support for the Taliban, the fighting in Afghanistan has become more intense and suicide attacks are being used more frequently.
Fighting has grown fiercer with
Afghan intelligence officials have criticised the West for not putting greater pressure on Pakistan and say they continue to submit evidence of the Pakistani government's support for the Taliban.
Pakistan says it is doing everything it can to target the fighters in the borderlands.
Following a major redeployment to the Taliban's southern heartland, British casualty rates in Afghanistan are now much higher than its casualties in Iraq, with 36 British soldiers killed since June.