The 27-year-old started his Olympic Games career at Sydney 2000, 12 years ago, where he finished fifth in the 200m Butterfly.
Six gold and two bronze medals at Athens 2004 were followed by his historic eight golds at Beijing 2008.
His London 2012 Games adventure did not start off so well with fourth place in the 400m Individual Medley - his worst result since Sydney 2000 - and he was shocked by Chad le Clos in the 200m Butterfly, the South African taking advantage of Phelps' poor glide into the wall.
However, the Baltimore swimmer won the 100m Butterfly and 200m Individual Medley - where he beat team-mate Ryan Lochte - as well as taking the titles in the 4 x 200m Freestyle and tonight's Medley Relay and silver in the 4 x 100m Freestyle.
SMS messages and phone calls from the likes of US president Barack Obama followed, and tonight he was presented with a FINA lifetime achievement award by president Julio Maglione inscribed with the words: 'To Michael Phelps, the greatest Olympic athlete of all time. From FINA. August 4 2012. London, Great Britain.'
After his final race, Phelps told a packed press conference: 'It's kind of weird looking at this (trophy) and seeing it say I am the greatest Olympic athlete of all time.
'I said to Bob (coach Bob Bowman) in the warm-down pool that I looked up to Michael Jordan, what he did in his career and I have been able to become the best swimmer of all time, we got here together and I thanked him. It was fine.
'He said "That's not fair. You were the one in the pool". I said "what's not fair"?
'My tears are in my goggles and yours are streaming down your face. I wouldn't be here without him. I love him to death and I am thankful to have someone like him. It has been great.'
On retiring, he added: 'I don't want to swim after I turn 30 and that is in three years and I don't want to swim for another three years.
'I would be past 30 by the time of the next Olympics. I have achieved what I wanted to achieve; Bob and I have somehow been able to do every single thing.
'If you can say that about your career then it's time to move forward, time to move on to other things.
'I finished my career how I wanted to.'
Phelps' retirement overshadowed the rest of tonight's programme, in which the USA women set a new world record in their medley race of 3:52.05.
Sun Yang also set a new world record in the 1500m Freestyle, lowering his own mark by more than three seconds to 14:31.02.
Ranomi Kromowidjojo completed the sprint 50m Freestyle, winning it in an Olympic record of 24.05.