Farah defended his 5,000-meter Olympic crown in the Estádio Olímpico Joao Havelange to add to his earlier successful defense of the 10,000m title he first won at London 2012.
Paul Kipkemoi Chelimo of the US originally finished second but was subsequently disqualified, pushing compatriot Bernard Lagat into the bronze medal position and Ethiopia's Hagos Gebrhiwet up to silver.
Farah's triumph means he becomes just the second man after Finland's Lasse Viren to win both the long-distance events at successive Olympics.
"It's every athlete's dream, but I can't believe it," Farah told reporters.
"I just want to go home now and see my beautiful kids and hang my medals around their necks."
The 33-year-old's triumph heralded wider success for Great Britain, which has now passed the 65 medals it achieved in London four years ago.
The 66th came shortly after Farah's win, as Christine Ohuruogu crossed the line to claim bronze for Britain in the women's 4x400m final.
Gold went to the US lineup of Courtney Okolo, Natasha Hastings, Phyllis Francis and Allyson Felix -- the country's sixth in a row in the event.
The last time the US failed to win the title was in Barcelona 1992. Meanwhile, Felix now has six Olympic gold medals to her name, more than any other female track athlete has achieved.
Another piece of US athletic history was made when Matt Centrowitz grabbed gold in the men's 1,500m final, the first time an American man has won that event since 1908.
It was down to the men of Team USA to close out the track and field events of Rio 2016 by surging home ahead of Jamaica in their 4x400m final, with defending champion the Bahamas in third.
Their success was the 13th gold, and 31st medal, in track and field events for the US in Rio.