By his own admission, Michael Phelps could not have scripted it better as he won back the title closest to his heart on an evening of pure gold for the most medalled Olympic athlete of all time.
The 200 metres butterfly was the first race he swam at an Olympics, at Sydney in 2000, and the gold that got away -- the one he wanted back after being beaten by a fingertip at the 2012 London Games by South African Chad Le Clos.
It hurt so much that Phelps made it his mission to exact revenge in Rio and win it one last time.
"Mission accomplished," he said after claiming the 20th Olympic gold of his career, a number that became 21 after he helped the U.S. team win the 4x200 freestyle relay in the evening's finale.
Japan's Masato Sakai ran him close to collect the silver in the butterfly, while Hungary's Tamas Kenderesi won bronze.
Le Clos, whose run-up to the Games was overshadowed by the devastating news that both of his parents had been diagnosed with cancer, finished fourth.
Phelps, who would have had four successive wins in the 200 butterfly but for that London race, has now amassed a record-extending 25 Olympic medals.
Some, however, carry far more significance than others.
"I really wanted that one back," said Phelps, who retired after 2012 but came back because he felt he needed to go out on his own terms.
"That event was kind of my bread and butter. That was the last time I'll ever swim it.
"Kind of having that come to an end, its crazy to think about ... I didn't say anything to anyone else, but there wasn't a shot in hell I was losing it."
Phelps said he had been prepared to leave "every ounce" in the pool, and strain every sinew, and did not know how close it had been until he was on the podium.
By then none of that mattered.
"Just being able to see the number one next to my name again, one more time in the 200 fly, I couldn't have scripted it any better," he said.
TENSE ATMOSPHERE
Stay informed. Subscribe to our newsletter
Phelps had touched the wall in one minute, 53.36 seconds, slower than his 2012 silver medal performance, with Sakai finishing in 1:53.40. Le Clos, who clocked 1:52.96 for gold in 2012, could only manage a 1:54.06.
With all eyes on the two big men on the blocks, both avoided eye contact as they waited to step up, standing almost back to back.
The tense atmosphere was cut by shouts from the crowd just as the swimmers were trying to compose themselves, the start aborted before they had taken racing positions and spectators urged to stay silent.
Le Clos, who won a 200 freestyle silver on Monday, reacted faster than Phelps at the start but it was Hungary's Laszlo Cseh who led at the turn with Phelps second and Le Clos third.
The American then used his mighty 'wingspan' to forge ahead into clear water.
Cseh began to fade, with Le Clos moving into second at the 150 metre-mark but the South African could not match Phelps in the final lap, with the American punching the air in delight after stepping out.
He laughed out loud on the podium, amused by friends in the crowd shouting out the familiar 'O' for the Baltimore Orioles baseball team while the U.S. basketball team looked on, and kissed the medal.
And then he went around the pool to embrace his partner and baby son Boomer. Mission accomplished.