It is the highest honor the president can give a civilian.
President Barack Obama bid farewell to Gates on Thursday, who has spent the past four-and-half years as Secretary of Defense under the administrations of Obama and George W. Bush.
"I can think of no better way to express the gratitude of the nation to Bob Gates than with a very special recognition," Obama said as he asked Gates to step forward to receive the award.
An emotional Gates quipped that he "should have known the president was getting pretty good at this covert ops stuff," an apparent reference to last month's secret raid in Pakistan that killed terrorist leader Osama bin Laden.
Obama called him a humble American patriot, a man of common sense and decency, and one of the nation's finest public servants.
Gates will be replaced by outgoing CIA Director Leon Panetta.
Also on Thursday, the Senate plans to vote on Obama's nomination of General David Petraeus to become the new CIA director, replacing Panetta.
The Associated Press contributed to this story.