Olympics special site; Photo gallery
Phelps, the most decorated Olympian in the history of the games had earlier confirmed that Rio 2016 will be his last games participation, thus today's (August 14) win means he will end his career on a high note.
USA has won gold in every 4x100 metre medley since 1960 Rome Olympics, except in 1980 when they had boycotted the Moscow Olympic Games.
Michael Phelps was swimming in the butterfly leg and the third leg, of the race as part of the US team alongside Ryan Murphy, Cody Miller, Phelps and Nathan Adrien.
Murphy gave a great start to the Americans, taking a big lead at the end of the first 100 metres, in the backstroke leg.
However, in the breaststroke leg Great Britain's Adam Peaty dominated the second 100 metres. Great Britain did not start the first 100 metres on a high as they were not even in the top 3 but it was Peaty who brought back his country into contention.
During the butterfly leg, that is third 100 meters, Phelps and Great Britain's James Guy fought very closely. Finally at the end Phelps went ahead of the British swimmer, giving USA the lead.
Great Britain finished second overall followed by Australia in the third place on the podium. With this win the champion and the greatest Olympian of all time finished his career on a high.