By Steve Keating

OMAHA, Nebraska (Reuters) - Michael Phelps edged old foe Ryan Lochte in a pulsating 200 meters individual medley showdown at the U.S. Olympic trials on Friday, adding another thrilling chapter to the greatest rivalry in swimming.

The race marked the last time Phelps and Lochte will go head-to-head in an American pool but the two swimming giants, who between them have amassed 33 Olympic medals, could clash one final time on the grandest stage of all, at the Rio Olympics in August.

Phelps, who had already qualified for a fifth U.S. Olympic team, held off his hard charging rival to narrowly get to the wall first in one minute, 55.91 seconds, the second fastest swim in the event this year.

But on this night the time did not matter as much as the result, the two swimmers who have pushed each to greatness looking up at the clock at the end, before turning their glances to each other and shaking hands.

"Ryan and I always have great races with one another," said Phelps.

"Him and I have been racing since 2004 and think when we race each other we bring each other to a different level. We take each other to that next step.

"It's probably the last time people in the U.S. will see that, the two of us race each other. We've had a great history in the 200 IM, 400 IM, 200 free, kind of every race."

While there were eight lanes occupied by swimmers all looking to punch their Rio Games tickets, for the soldout crowd at CenturyLink Center this was a match race of the highest order, a duel in the pool between two 31-year-olds who lined up beside each other.

In lane five was Phelps, the winner of a record 22 Olympic medals who has made the gold medal in the 200 IM his personal property taking top spot on the podium at the last three Summer Games.

In lane four, Lochte, the winner of 11-Olympic medals and runner-up to Phelps in the 200 IM at the 2004 Athens and 2012 London Games and the world champion and record holder in the event.

Phelps, who turned 31 on Thursday, as usual went out fast and stayed in front leading after every split but as they turned for home a battling Lochte chased down his rival on the freestyle leg.

Matching each other stroke-for-stroke the crowd of 14,000 now on its feet roaring, Phelps dug a little deeper getting home just .31 seconds ahead of his rival.

"I knew going in that this was going to be a dog fight until the end," said Lochte. "I love racing against him.

"It was kind of a little heartbreaking at the end because after we finished, we gave each other a hug and said good job, but we both knew that was probably the last time me and him were going to race each other on U.S. soil."

(Editing by Andrew Both)