By Mark Trevelyan

RIO DE JANEIRO (Reuters) - Michael Phelps of the United States won the Olympic 200 meters individual medley on Thursday to capture the 22nd gold medal of his career and become the first swimmer to win the same event at four consecutive Games.

Japan's 400 IM champion Kosuke Hagino won silver and Wang Shun of China took bronze, both moving dramatically through the field on the final length after turning in fifth and seventh place.

It was yet another extraordinary swim for Phelps, 31, who has now won two individual and two relay golds at his fifth Olympics, two years after coming out of retirement.

His medal haul has now risen to 26, including two silvers and two bronzes, with the 100 butterfly final still to come on Friday. Thirteen of his golds have come in individual races, the rest in relays.

"Right now I don't know how to wrap my head around that. I don't know what to say. It's been a hell of a career," Phelps told reporters, while acknowledging the strain on his 31-year-old body.

"That hurt a lot ... my body is in pain, my legs are hurting, I'm tired."

Despite winning four golds in London in 2012, Phelps has said he was dissatisfied with his preparation and results there and wants to bow out on his own terms.

"The biggest thing for me through the meet so far is I've been able to kind of finish how I wanted to. I've been able to come back and I've been able to accomplish things that I just dreamt of," he said.


He was lauded by the Rio crowd, with one banner proclaiming "Phelps Greatest Olympian Ever". At the medal ceremony he swayed slightly and breathed deeply, his eyes moist, as he listened to the U.S. anthem.

Phelps then raised his arms to salute the crowd as fiancee Nicole cradled their baby son Boomer in the stands.

There was little time to savor the moment, however, as he raced back off the pool deck to get ready for the semi-finals of the 100m butterfly, which he also has the chance to win for a fourth successive Games.

He finished second in his semi-final to qualify fifth fastest for Friday's final.

In the medley, Brazil's Thiago Pereira went off fastest, leading from Phelps after the butterfly leg, with Ryan Lochte of the United States and Hagino neck-and-neck just behind.

With the Rio crowd's excitement mounting, the three turned almost together after the backstroke, with Lochte just 0.01 seconds ahead.

Phelps led from Pereira and Lochte at the final turn and powered on as the other two faded, opening the way for Hagino and Wang to grab the two other medals.

Phelps clocked one minute, 54.66 for a comfortable winning margin of 1.95 seconds.

Japan's Hiromasa Fujimori was fourth and Lochte fifth in the last individual race of his long career, with a flagging Pereira seventh.

Phelps' four consecutive golds in the same event are unique for a swimmer, and place him in the same Olympic pantheon as fellow-Americans Al Oerter in the discus and Carl Lewis in the long jump.

(Reporting by Mark Trevelyan; Editing by Greg Stutchbury)