RIO de JANEIRO — If Thursday night’s men’s 200m individual medley final between Michael Phelps and Ryan Lochte was the end, as Jim Morrison and the Doors once said, it made — in a riff on what Morrison also told us — for no safety yet a big surprise, a race in which two of the best, ever, pushed each other one final time.

Each in his own lane, literally and figuratively, Phelps and Lochte have for years been on a similar quest. Their mission: to push boundaries in search of excellence.

As Morrison put it, to be limitless and free.

At these Rio 2016 Olympics, a Games he repeatedly has declared will be his last, Phelps on Thursday night staggered the field over the final 100 meters to win the 200m IM, and by nearly two seconds. 

It made for his fourth straight Olympic victory in the 200m IM and his 22nd gold over five Games, 26th medal overall. Phelps joined the track and field stars Carl Lewis and Al Oerter as the only Americans to win an individual event four times.

He touched in 1:54.66. He now has 13 individual Olympic golds.

Japan’s Kosuke Hagino, winner earlier at these Games of the 400m IM, took second, in 1:56.61. China’s Wang Shun got third, 1:57.05.

Lochte, leading after 100 meters, third at 150, faded to fifth, 1:57.47.

“Every single day,” Phelps said, “I’m living a dream come true.”

Lochte said, “He has separated himself from everyone, not just in swimming but in all Olympic sports. He is the king.”

Thus will history record the latest, avowedly the last, turn in the Phelps-Lochte road show.

They have been rivals and competitors. 

Friends, too, at times better friends than not, at times not than better. As the two have moved into their 30s, they have more readily displayed a genuine, profound respect for the other. 

Who else but Ryan Lochte could possibly know what life is like for Michael Phelps? 

Who but Michael Phelps could possibly appreciate the greatness — and it is greatness — of Ryan Lochte, and how the two of them have made each other better?

Coming into Thursday night, either Phelps or Lochte had won the 200m IM at 12 of the last 13 major international meets.

As Phelps said after Wednesday’s semifinals:

“I consider that Ryan and I have probably grown closer together as friends this year than we have in the past. We have one more time to hop in the pool and duke it out.” 

It’s in that spirit that Lochte — as well as men’s 200m backstroke gold medalist Ryan Murphy — did Phelps a huge turn Thursday night after the 200m IM in anticipation of Phelps’ next event, the 100m butterfly, the kind of thing that you might see only when it’s pointed out and then you go, of course.

Lochte and Murphy bought Phelps extra time. Which he needed. Because, as he would say after the 100m fly, “That hurt a lot.”

The medley final was supposed to start at 11:01 p.m. local; go time turned out to be 11:09. Phelps was out of the water at 11:13. Lochte took a long, long time getting out of the pool afterward; he was by far the last guy out of the eight. 

The first of the two men’s 100m fly semifinals, in which Phelps was also racing, was due to begin at 11:34.

Goodness, but then Murphy, in his day-glow yellow sneakers, took a long time leading the backstroke medalists around the deck after their medal ceremony, which immediately followed the men’s 200 IM. Their official guide kept motioning, let’s go. And still Murphy kept posing for pictures.

Then came the 200m IM ceremony, Phelps posing only for one set of pictures and holding up four fingers, signifying either his fourth gold medal of the Rio 2016 Games or fourth straight 200m IM gold, take your pick. Hagino and Wang walked around the pool to the photo station. Pictures. More pictures.

At 11:45 p.m., the ready room camera showed Phelps, earphones on, tying his swim suit. The first 100m fly semi went off at 11:48. Phelps swam 51.58, qualifying fifth overall for Friday night’s final, he had been eighth at the turn but finished second in the semi, behind Hungary’s Laszlo Cseh. Singapore’s Joseph Schooling emerged as the top qualifier, 50.83.

The haters can’t get past Lochte’s fun quotient. But that’s all just for show. In the pool, like the revolutionary underwater turn Lochte has perfected, he is all business — never quite getting the credit due for the years of hard yards he has put in. Moreover, when the racing is over, Lochte is one of the kindest, most thoughtful and deceptively smart guys you would ever meet. 

Here, in one paragraph, is why Ryan Lochte deserves a full measure of appreciation. He said after the race: “In life, in swimming, in sports, there are always ups and downs. It is what you do when you have those downs who make you what you are. That,” meaning fifth place in that 200m IM, “is a low for me. I have to bring myself up. I have to go back into those stands and cheer on Team USA.”

Back to the minute-by-minute timing of the Olympic schedule. This might seem mundane. It is not. Indeed, the actual order of events at the Games underscores what an extraordinary achievement it is for Lochte to have won any medal at prior Games in the 200 IM.

At an Olympics, the men’s 200 IM and men’s 200 backstroke finals go the same night. At previous Games, Lochte has sought medals in both events. In Beijing, for instance, he won 200m back gold; in London, 200m back bronze.

Then, roughly a half hour later, he would go out and match it up with Phelps in the 200m IM — even though the 200 back is a killer that takes it out of your legs. If from the overhead TV camera, swimming seems to be all arms, that’s a mirage; it’s mostly the legs.

At the 2012 London Olympics, Phelps and Lochte went 1-2 in the 200m IM. In Beijing in 2008, 1-3 (Cseh took silver). In Athens in 2004, 1-2.

For 2016, Lochte did not try at the U.S. Trials about a month ago in Omaha to qualify for the 200 back. 

In theory, that means he should have had more in the tank.

But no. 

“It has been a long journey,” Lochte said after Thursday’s 200m IM. ”I think now it is time for me to take a break, mentally and physically, to just get myself back to when I was a little kid having fun again. I can’t say this is my last time swimming. So we will see what happens.”

Phelps, meanwhile, is arguably in the best shape of his life — or at least in condition comparable to his prime, the 2008 Beijing Games and 2007 world championships in Melbourne, Australia, when he was unbeatable. 

Phelps turned 24.91 for the butterfly leg, the first of the four, 28.54 next in the backstroke. At that point, he was second, behind Lochte. 

Then Phelps opened it up. He went 33.51 in the breast and 27.7 coming home in the free, opening up a lead of more than a body length.

The 100 fly and, presumably, the medley relay are yet to come. That will be, if Phelps’ guarantee holds that these are really his last Games, the end. 

Limitless and free. You saw it Thursday.

“The biggest thing for me through the meet so far,” Phelps said, “is I have been able to kind of finish how I wanted to. I have been able to come back and been able to accomplish things i just dreamt of,” adding a moment later, “This has been a very, very special week so far — for me closing out my career.”

Join our Newsletter for the latest news right to your inbox