Philip flew to St Barbara's Barracks at Bad Fallingbostel in Germany to give servicemen from The Highlanders, 4th Battalion The Royal Regiment of Scotland - also known as 4 Scots - their honours.
Speaking on the parade ground, the Duke, who is the unit's royal colonel, told more than 400 men and their officers: "I am delighted to have been asked to present these campaign medals on this occasion, and I am only sorry that D Company is not here to receive theirs as well.
"Well, as you know, this is the conclusion of the battalion's third deployment to Afghanistan, and I believe everyone involved can look back with satisfaction at a job very well done. I think we should never forget that it was at the cost of three killed and nine seriously wounded."
He went on to say that everyone also recognised the contribution made by wives, families and friends, and that he hoped they enjoyed their leave together.
The medals presented by Philip recognised those who had served in Afghanistan for the first time.
The focal point of yesterday's parade were the battalion colours, which were presented to the unit in Kinloss by Philip in 2011, immediately after their return from operations in Afghanistan.
The recent tour for the main body of the battalion lasted eight-and-a-half months and more than 100 soldiers from D Company are still in Afghanistan.
During the visit, the Duke had an informal lunch in the officers' mess and also visited the sergeants' mess.