RIO DE JANEIRO — Each day at the 2016 Olympics seems to bring another “last” for the soon-to-retire Michael Phelps.

He teared up Tuesday after his last final in the 200-meter butterfly, the race that started it all in his peerless Olympic career. On Thursday, he prepared to swim for the last time against the man who has chased him most relentlessly — Ryan Lochte.

But as it turned out, the race was not a duel between near-equals. It was a master class from Phelps, who's proving with every swim at these games that he's the greatest his sport has ever seen.

Phelps won in 1 minute, 54.66 seconds, nearly two seconds ahead of silver medalist Kosuke Hagino of Japan. Lochte finished fifth, almost three seconds behind.

“I just wasn't good enough tonight,” Lochte said.

The 200 IM should have been a difficult race for Phelps, stuffed as it was between his preliminary heat and his semifinal for the 100-meter butterfly. But he pulled away on the breaststroke leg, generally his weakest, and was never in danger over the last 50 meters.

With his victory, Phelps became only the third male, after Al Oerter in the discus and Carl Lewis in the long jump, to win the same event four Olympics in a row. He shook his head as if he couldn't quite believe it when his achievement was announced in the arena. He was already the only male swimmer to have won the same event three times in a row, a feat he'd achieved in both the 200?IM and the 100?butterfly.

The Baltimore native also became the winningest individual gold medalist of all time, with his 22nd, surpassing Leonidas of Rhodes, who won his last races in 152?B.C. Phelps also holds the record for most medals overall with 26.

Lochte, the most persistent antagonist in Phelps' Olympic biography, stood in his way. And both men seemed to anticipate another side-by-side battle.

“Him and I have duked it out back and forth,” Phelps said. “This is a special one to both of us. He's the world-record holder and I'm the defending champion.”

The final showdown — well, probably, given that Lochte has predicted Phelps will again unretire — was the highlight of Phelps' busiest day at the Olympics. In the afternoon, he swam the fourth-fastest qualifying time in the 100 butterfly, and he came back about 30 minutes after his 200?IM victory to finish second in his evening semifinal, earning a place in tonight's final.

Phelps, 31, said the nighttime butterfly race would be his most challenging of the week because of the heavy workload.

The 100 butterfly could also bring him back into competition with South African Chad le Clos, the swimmer associated with Phelps' sour face that became a social-media sensation early in the week.

Phelps feels no such animus toward Lochte. They share a suite in the Olympic Village and chuckled together Tuesday on the pool deck before the 4x200-meter freestyle relay. That's not unusual. Lochte is one of the few swimmers who can crack Phelps' steely prerace focus. Before the 200 IM final at the Olympic trials, he stepped on the back of Phelps' shoe as they walked out to race, causing Phelps to giggle. And then they swam away from the rest of the field, neck and neck from start to finish. That's just how they do it.

You could argue Lochte is the swimmer whose reality has been most altered by Phelps' enduring greatness. In a Phelps-less world, the jovial Floridian might have been the one to set a standard for winning Olympic gold. Aside from Phelps, he has won more career medals than any other male Olympic swimmer. He's indisputably one of the finest all-around swimmers in history and yet he'll be remembered as a B-side.

Lochte doesn't seem to resent that reality. He's more apt to credit Phelps for inspiring him to continue swimming at a high level.

“Sometimes, I think I wouldn't be the swimmer I am today if it weren't for Michael,” he said.

Lochte has acknowledged his sadness at the idea of racing Phelps for the final time. At 32, he's a year older than his friend. But he already said he will likely continue swimming past these Olympics. He'll stop when he no longer enjoys it, which might mean never.

Though Lochte is known for oddball gestures like the bluish-gray dye job he chose for his Olympic haircut, he and Phelps share a rare zeal for racing. It's uncanny how often they swim side by side when pitted against each other in the 200 IM, their signature race. Between them, they hold the top 13 times ever in the event.

Lochte set the world record in the 2011 race in which Phelps swam his personal-best time. But Phelps has always gotten the better of Lochte in the Olympics, where he has beaten him in three 200?IM finals. It's the story of their careers in microcosm.

Lochte said he would need to swim a perfect race to beat Phelps this time. And he turned out to be more right than he knew.

Phelps, meanwhile, knew his competition would go beyond Lochte. Hagino had swum the best time of 2016 coming into the Olympics and had beaten Phelps' protege, Chase Kalisz, in the 400 IM on Saturday. And the atmosphere at the Olympic Aquatics Stadium was deafening with Brazilian Thiago Pereira among the swimmers trying to knock Phelps from his throne.

All week, the Brazilian fans have greeted their hometown favorites with songs, whistles and waving flags. They love Phelps, too, but he does not bleed green, blue and gold.

Phelps knew he'd have his own home crowd cheering for him about 4,800 miles away when the Ravens broadcast his race on the video boards at M&T Bank Stadium during a break in their preseason game against the Carolina Panthers. Fans and players from both teams erupted as they watched Phelps win again.

“It's exciting,” he said. “I've missed not going to practice this year. I'm looking forward to football season.”

childs.walker@baltsun.com

twitter.com/ChildsWalker