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.
‘I’m the greatest’
“There you go. I’m the greatest,” said Bolt, after bringing an end to one of the most astonishing Olympic careers of all time.
In February, Bolt confirmed he would retire after the 2017 World Championships in London and will not compete at Tokyo 2020, at which point he will be nearly 34.
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.
“I’m going to stay up late and have fun. I never knew this would happen when I started out,” Bolt told BBC Sport.
“My team came through for me tonight. As long as we got the baton round, it was never in doubt.”
Blake made an attempt to persuade 100m and 200m world-record holder Bolt to continue for another four years, saying: “Usain needs to be immortal and he is immortal. I will encourage him to come back for 2020.”
|Bolt’s Olympic ‘triple triple’|
|Beijing 2008||100m, 200m, 4x100m|
|London 2012||100m, 200m, 4x100m|
|Rio 2016||100m, 200m, 4x100m|
USA were disqualified
The American team of Mike Rodgers, Justin Gatlin, Tyson Gay and Trayvon Bromell celebrated winning a bronze before they were disqualified.
The USA team were told it was because Gatlin received the baton too early from Rodgers in the first handover, but they are now appealing against the decision.
“We already did the victory lap and then when we talked to TV, they told us,” said Gay.
“They said Justin got the stick before the zone. He’s saying he didn’t.”
The GB quartet of Richard Kilty, Harry Aikines-Aryeetey, James Ellington and Adam Gemili, who finished sixth, were promoted to fifth.
Gemili, the British athletics team captain who narrowly missed out on 200m bronze, said: “They are a great team. It is a real shame, especially for me after yesterday.
“I got back in the village at 1:30am and everyone was up waiting for me. We have such a great team and team spirit.
“We are disappointed not to win a medal; we know we are capable of it.”
‘An incredible man’
Four-time Olympic gold medallist Michael Johnson: “This was an incredible race. USA were in it. Japan were in it. Jamaica just had to get it round to Usain Bolt. He had to chase the Japanese team but Bolt – flawless. All gold. No silvers. No bronze. A fantastic performance at these championships.”
Two-time 110m hurdles world champion Colin Jackson: “Usain Bolt is just too good. Once he got that baton he had to ease himself past Japan and once he got in his stride nobody was going to catch him. An incredible man, a wonderful athlete and we are all incredibly pleased he has done what he has done.”