Bolt, 29, had won the 100m and 200m in Rio and is the only man to win all three sprint events at three Games.
He combined with Asafa Powell, Yohan Blake and Nickel Ashmeade to finish in 37.27 seconds.
Japan won a surprise silver and the USA were disqualified to hand Canada bronze and lift Britain up to fifth.
In February, Bolt confirmed he would retire after the 2017 World Championships, meaning Rio marks the end of one of the greatest Olympic careers of all time.
His haul of nine gold medals is the joint highest among Olympic athletics, equal with USA sprinter and long jumper Carl Lewis and Finnish long-distance runner Paavo Nurmi.
(BBC News)