David Cameron has warned the Taliban not to "wait it out" in Afghanistan until troops withdraw in 2014.
The PM said British support for the country would remain long after the planned exit date, which will see all international combat forces leave.
Afghan security forces are "capable and large" but Britain's support for the nation will continue for many years, he said.
"The Taliban should be in no doubt that we will handing over to a very large, very capable Afghan security force," Mr Cameron said at a joint press conference with Afghan president Hamid Karzai, held in the gardens of the presidential palace.
He added: "You cannot wait this out until foreign forces leave in 2014 because we will be firm friends and supporters of Afghanistan long after 2014."
Pakistan prime minister Raja Pervaiz Ashraf is understood to have delayed his visit to Afghanistan so he could coincide with his British counterpart's visit.
Mr Cameron said: "The terrorists that are trying to wreck Afghanistan are the same terrorists that are trying to wreck Pakistan.
"This is one fight that we all need to be engaged in to save Afghanistan from Talibanisation and we need to do the same to help Pakistan, which is threatened by a very similar terrorist threat. So we should be together in one single fight because it's in all our interests to have a stable, peaceful, democratic Afghanistan and a stable, peaceful, democratic Pakistan."
Mr Karzai praised Mr Cameron for being a long-term friend of the nation.
The two leaders signed a memorandum of understanding on the planned "Sandhurst in the sand" training academy, which will see British military leaders train their Afghan counterparts.