LONDON — As if 22 medal ceremonies over the last three Olympics weren’t enough, Michael Phelps was summoned back to the pool deck for one more accolade.

This time, he received a trophy rather than a medal, an award that sought to sum up a career like no other.

“To Michael Phelps,” it said, “the greatest Olympic athlete of all time.”

In a final race that was more a coronation than a contest, Phelps headed into retirement the only way imaginable — with an 18th gold medal. Reclaiming the lead with his trademark butterfly stroke, the one seen in his Olympic debut as a 15-year-old in Sydney a dozen years ago, he capped off a mind-boggling career with a victory in the 4x100-meter medley relay Saturday.

“I’ve been able to do everything that I wanted,” Phelps said.

When it was done, he hugged his teammates — Matt Grevers, Brendan Hansen and Nathan Adrian — before heading off the deck for the final time in his hip-hugging swimsuit. He waved to the crowd and smiled, clearly at peace with his decision to call it a career.

And what a career it was!

“I was able to really put the final cherry on top tonight, put all the whipped cream I wanted and sprinkles. I was able to top off the sundae,” Phelps said. “It’s been a great career. It’s been a great journey. I can’t be any more happy than I am.”

Phelps retires with twice as many golds as any other Olympian, and his total of 22 medals is easily the best mark, too.

The 27-year-old could surely swim on for another Olympics, maybe two, but there’s really no point.

“I told myself I never want to swim when I’m 30,” Phelps said. “No offense to those people who are 30, but that was something I always said to myself, and that would be in three years. I just don’t want to swim for those three years.”