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.