Amid chaotic waters in Tokyo, at this time in 2012 Phelps broke Olympic world record

USA's Michael Phelps celebrates with his Gold Medal after winning the Men's 4 x 200m Freestyle Relay Final, the gold medal secured Phelps a record 19th Olympic medal, at the Aquatics Centre in the Olympic Park during the fourth day of the London 2012

As a tumultuous nine days of swimming came to a close at the Tokyo Aquatics Centre, at this time during the 2012 Olympic Games in London Michael Phelps broke the record to win the most Olympic medals ever. 

On July 31, 2012, he won his 19th medal in the 4x200-meter freestyle relay, moving one ahead of Soviet gymnast Larisa Latynina, who got her haul in 1956, 1960 and 1964. And he wasn’t even close to being done winning yet. 

Phelps went on to win another nine medals, making him the most decorated athlete in the history of the Summer Games. He’s won 28 medals across five Olympics — 23 of which are gold. 

Phelps announced his retirement at the end of the London Games, though he couldn’t stay out of the water. He made a final appearance at the age of 31 four years later in Rio, coming a long way from the 15-year-old he was when he made the team for Sydney in 2000. 

In Tokyo, Hungary's László Cseh outlasted Phelps and fellow longtime American rival Ryan Lochte at the age of 35, though Cseh has never won gold in the five Olympics he's competed. The peak of his career coincided with Phelps' dominance.

In this year’s games, American Caeleb Dressel has been billed as Phelps’ successor after Lochte failed to make the U.S. team in what would have also been the 36-year-old's fifth Olympics.

On Sunday, Dressel became only the fifth swimmer to capture five gold medals in a single Olympics. He capped his Games with a dominant victory in the 50-meter freestyle and a dazzling butterfly leg on the U.S. team that broke a 12-year-old world record to capture gold in the 4x100 medley relay.

He was hoping to sweep his six events, which would have made him only the fourth swimmer and fifth athlete overall to win six gold medals at a single Olympics.

Phelps, of course, did that twice

He captured six golds at the 2004 Athens Games before setting the record with eight in Beijing four years later.

RELATED: Tokyo Olympics: Americans wrap up swimming events with medals, milestones

The only gold Dressel didn't win came in a race he never had a chance in.

The Americans went with a different lineup than everyone else in the 4x100 mixed medley relay, a new Olympic event that features two men and two women swimming in any order.

While every other finalist used a woman on the anchor freestyle leg, the U.S. coaches went with Dressel. They knew he'd be behind at the final changeover, but never expected him to dive in more that 8 seconds off the lead.

That was far too much for even a swimmer of Dressel's talents, though he did pass three swimmers to pull the Americans from last to fifth.

RELATED: Tokyo Olympics: Dressel wins swimming gold; Aussie beats Ledecky

While Dressel’s performances have been stellar, the Americans had some high-profile disappointments in the water earlier in the week.

Katie Ledecky was beaten twice by Australia's Ariarne Titmus, the swimmer known as the Terminator becoming the first to beat the American star in an individual race at the Olympics.

And Simone Manuel, one of the biggest stars in Rio, qualified in only one individual event and didn't make the final.

More shocking, the U.S. failed to earn a medal in not one, but two relays. Before these games, the Americans had never entered a relay and missed out on the top three.

Dressel said those results were unacceptable for a country with more swimming depth than any other.

"The standard for the U.S. is gold," he said. "Next year at worlds, we’ll give that another go," he added, already looking ahead to the 2022 championships in the southern Japan city of Fukuoka.

RELATED: Michael Andrew, the unvaccinated US swimmer, goes maskless at Tokyo Olympics

Meanwhile, Phelps is still a part of this year’s games. NBC hired him primarily as a swimming analyst, though his activism and willingness to talk about his own mental health issues has provided a crucial element to some of their unanticipated coverage — Simone Biles' decision to pull out of the team and all-around gymnastics competition

Phelps said he understood how Biles felt as though she carried the weight of the world on her shoulders, since he felt it, too. 

He has long been open about his own mental health struggles. Phelps has said he contemplated suicide after the 2012 Olympics while wracked with depression.

He said watching Biles struggle "broke my heart."

"Mental health over the last 18 months is something people are talking about," he said. "We’re human beings. Nobody is perfect. So yes, it is OK not to be OK."

RELATED: Simone Biles withdrew from Olympics gymnastics final to protect team, self

This story was reported from Detroit. The Associated Press contributed.