Mr Hammond said servicemen and women were aware of the risks involved but took pride in their work.
“The people on the ground are acutely conscious of the risks that they are running, but they are also incredibly proud of the job that they are doing and rightly so, and hugely satisfied by the level of public support they have back home,” he said.
“Morale on the ground in Afghanistan is extremely high, and it’s high because the servicemen and women there know that they are doing a job and are doing it well.”
Mr Hammond added: “The judgment is that Afghanistan would still be a very preferred base for terrorist training and activity if we were not there. The nature of the terrain makes it very attractive to international terrorists.
“We have done a great job there, our troops have done a fantastic job in clearing and holding the ground and squeezing al-Qaeda out of Afghanistan.
“We are nearly there. We have put in a huge amount of effort.
“We just need, over the next two and a half years, to complete that task, then we can leave with our heads held high.”