Michael Phelps Michael Phelps

[SPOILER ALERT: The following story reveals the outcome of Friday's Olympic swimming finals.]

Michael Phelps started out the London Olympics slowly, but he's definitely going out — and out of the sport — on top.

Olympics: The top moments (so far!)

The swimmer won his final individual event, the 100-meter butterfly, on Friday, to nab his 21st career medal and 17th gold. The win also marks the second time in as many days that Phelps has three-peated in an individual event. He was the first male swimmer to do so Thursday in the 200-meter individual medley.The 100 fly has always been a bit dicey for Phelps — he won the past two at the Olympics by a combined margin of 0.05, including memorably out-touching Serbia's Milorad Cavic in Beijing by 0.01. But this time he was comfortably ahead by 0.23, touching in at 51.21. South Africa's Chad Le Clos, who upset Phelps in the 200 fly, and Russia's Evgeny Korotyshkin tied for second at 51.44.Phelps was seventh at the wall, but as usual, he turned it on in the final 50 meters and pulled away at the end.

Olympic Moment: Who came out on top in Michael Phelps and Ryan Lochte's final showdown?

Phelps, 27, was aiming for the historic three-peat in four individual events in London, but came up short in his first two, placing fourth in the 400 IM and second in the 200 fly.He has one race left, Saturday's 4x100-meter medley relay, in which he'll swim the butterfly leg. The U.S. men have never lost the event at the Olympics. After that? Retirement.