In the next lane, Milorad Cavic was gliding to the finish, just inches from the gold, his arms no longer driving but just reaching for the end.
That's all Phelps needed. He didn't have to be the fastest. Just first.
Phelps swam into history with a magnificent finish Saturday, tying Mark Spitz with his seventh gold medal by the narrowest of margins in the 100-meter butterfly.
He got his hands on the wall a hundredth of a second ahead of Cavic - a finish so close the Serbians filed a protest and swimming's governing body had to review the tape down to the 10-thousandth of a second.
"I had no idea," Phelps said. "I was starting to hurt a little bit with probably the last 10 meters. That was my last individual race, so I was just trying to finish as strong as I could."
Phelps' time was 50.58 seconds, the only time in these Olympics that he won an event without breaking the world record.
Not to worry. The 23-year-old from Baltimore has now pulled even with the greatest of Olympic records, matching Spitz's performance in the 1972 Munich Games.
Call this one the Great Haul of China - and it's not done yet.
Phelps will return on Sunday to swim in his final event of these games, taking the butterfly leg of the 400 medley relay. The Americans will be heavily favored to give him his eighth gold, leaving Spitz behind.
Phelps pounded his fist in the water and let out a scream after the astonishing finish. The crowd at the Water Cube gasped - it looked as though Cavic had won - then roared when the "1" popped up beside the American's name.
Cavic's time was 50.59.
The Serbian delegation filed a protest, but conceded that Phelps won after reviewing the tape provided by FINA, swimming's governing body. USA Swimming spokesman Jamie Olson said the tape was slowed to one frame every 10-thousandth of a second to make sure Phelps actually touched first.
It was impossible to tell on regular-speed replays.
"We filed the protest but it is already over," said Branislav Jevtic, Serbia's chief of mission for all sports. "They examined the video and I think the case is closed. The video says (Phelps) finished first.
"In my opinion, it's not right, but we must follow the rules. Everybody saw what happened."
Sports Illustrated staff writer Brian Cazeneuve told CBS News, "It's very unusual, because it's not required. ... In this case, they felt the results were definitive so they brought them in frame-by-frame, 'Hhey, here's what happened.' And then afterwards, the Serbs were convinced. They were satisfied. They said, 'OK, that's it with our protest." '
Cavic wasn't sure he actually lost, but said he would accept the result.
"I'm stoked with what happened," Cavic said. "I don't want to fight this. People will be bringing this up for years and saying you won that race. If we got to do this again, I would win it."
A notoriously slow starter - Phelps was seventh out of eight at the turn - he really turned it on with the return lap, his long arms windmilling through the water as he closed the gap on Cavic and fellow American Ian Crocker, the world record-holder.
As they approached the finish, Cavic took his final big stroke and reached for the gold. Phelps, his timing a bit off but fully aware of where he was, did another mini-stroke and actually slammed the wall with his hands on the follow-through.
"I actually thought when I did take that half-stroke, I thought I lost the race there, but I guess that was the difference in the race," Phelps said.
It was reminiscent of the 100 fly finish at Athens four years ago, where Crocker appeared to have the race won but Phelps got him at the wall by 0.04.
"My last two Olympics I've been able to nail my finishes, and it's been by four one-hundredths and one one-hundredths," he said. "I'm happy and kind of at a loss for words."
Andrew Lauterstein of Australia won the bronze medal in 51.12. Crocker was again denied the first individual gold of his career; he didn't even win a medal, finishing fourth by a hundredth of a second in 51.13.
"It was a tight one," Crocker said. "I saw my short differential between getting a medal or not, but then I realized Michael's was pretty close, too. I'm really glad that he came out on top.
"It was everything that an Olympic final should be. It doesn't matter who's in the heats, you just got to get out and race and it's anybody's game. It was one of the more intense races that I've been in, which makes it a great way to end the meet."
While the medley relay figures to be nothing more than a coronation, Phelps isn't ready to talk about No. 8.
"It's not over yet," he said. "I really think the Australian team looks great for the relay. It's going to be a race."