The 3rd Battalion The Rifles (3 Rifles) took part in a homecoming parade down the Royal Mile from Edinburgh Castle to Holyrood Palace.
An Army spokeswoman said they received a “heroes’ welcome”.
She said: “You couldn’t walk down the pavements of the Royal Mile because there was that many people waiting to see them.”
The spokeswoman said the soldiers were greeted with cheers by the good natured crowds. She said: “The guys looked pretty emotional, pretty choked, they looked pretty moved.”
Lieutenant Colonel Nick Kitson, Commanding Officer, said: “We’re absolutely thrilled and proud to be marching down the Royal Mile. The support of the people of Edinburgh certainly helps to boost morale after the last six and a half months.”
A Lothian and Borders Police spokesman said there was a “nice turnout” with people standing six deep to watch the parade.
The 3 Rifles returned to their Edinburgh barracks last week after their Afghan tour during which 14 soldiers were killed.
The soldiers were in Helmand province as part of a 1,400-strong battlegroup which included a company from 1st Battalion the Royal Regiment of Scotland, a company from 4th battalion the Rifles and other attached personnel.
During the tour 30 members of the battle group were killed, 14 of them from 3rd Battalion the Rifles. Although based at Redford Barracks, 3rd Battalion the Rifles recruits mainly from Yorkshire and North East England.