When Phelps touched the wall, he finally had gold at his final

Olympics.

And a record for the ages.

Phelps swam into history with a lot of help from his friends,

taking down the last major record that wasn't his alone. He took

the anchor leg for the United States in a gold medal-winning

performance of the 4x200-meter freestyle relay Tuesday night,

earning the 19th Olympic medal of his brilliant career, and the

15th gold.

A more appropriate color.

"I've put my mind to doing something that nobody had ever done

before," Phelps said. "This has been an amazing ride."

About an hour earlier, Phelps took one of his most frustrating

defeats at the pool, blowing it at the finish and settling for

silver in his signature event, the 200 butterfly.

That tied the record for career medals held by Soviet gymnast

Larisa Latynina, but it was hardly a triumphant moment. Phelps

slung away his cap in disgust and struggled to force a smile at the

medal ceremony.

But any disappointment from that race was gone by the time he

dived in the water on the relay, having been staked to a huge lead

by teammates Ryan Lochte, Conor Dwyer and Ricky Berens.

Before the race, they all huddled together, fully aware of their

role in history.

"I thanked those guys for helping me get to this moment,"

Phelps said. "I told those guys I wanted a big lead. I was like,

'You better give me a big lead going into the last lap,' and they

gave it to me. I just wanted to hold on. I thanked them for being

able to allow me to have this moment."

Berens handed off a lead of nearly 4 seconds to Phelps, who was

extra cautious with the exchange, knowing the only way he could

ruin this one was to get disqualified.

Lochte stood on the deck, waving his arms. Dwyer and Berens

pumped their fists. And Phelps touched the wall for his first gold

of the London Games with a cumulative time of 6 minutes, 59.70

seconds.

No one else was close. France's Yannick Agnel swam a faster

final leg than Phelps, but it wasn't nearly good enough, his

country taking silver in 7:02.77. China was far back in third at

7:06.30.

"Congrats to Michael Phelps for breaking the all-time Olympic medal record. You've made your country proud," tweeted President Barack Obama.

Phelps might have backed into the record a bit by failing to win

any of his first three events at these games, but there's no

denying his legacy as one of the greatest Olympians ever - if not

THE greatest.

"The legacy he has left behind for swimming is fantastic,"

said South African Chad le Clos, the guy who beat him in the

butterfly. "Even in Africa, everyone knows Michael Phelps."

Phelps has 15 golds in his career, six more than anyone else, to

go along with two silvers and two bronzes. After failing to medal

in his only race at the 2000 Sydney Games, he won six golds and two

bronzes in Athens, followed by his epic eight gold medals in

Beijing. And now the swan song, not nearly as epic but enough.

Latynina won nine golds, five silvers and four bronzes from

1956-64.

"You are now a complete legend!" the public-address announcer

bellowed, accompanied by the Foo Fighters' song "Best of You."

Phelps still has three more events in London before he retires,

three more chances to establish a mark that will be hard for anyone

to touch.

"It has been a pretty amazing career," the 27-year-old said,

"but we still have a couple races to go."

Several fans held up a bedsheet with "PHELPS GREATEST OLYMPIAN

EVER" handwritten on it.

Michael Phelps looks on from the water after earning his record 19th Olympic medal while his teammates celebrate their win in the 4x200-meter freestyle relay. AP Photo/Mark Duncan

Hard to argue with that, though this hasn't exactly been the

farewell Phelps was hoping for -- a sluggish fourth-place finish in

the 400 individual medley, a runner-up showing in the 4x100 free

relay, then another silver in the 200 fly.

The 200 fly was a race he had not lost at either the Olympics or

world championships since Sydney, when he finished fifth as an

unknown 15-year-old just soaking up the moment, a kid with big dreams but no idea they would turn out like this.

Phelps, after leading the entire race, tried to glide into the

wall instead of taking one more stroke. Le Clos took that extra

stroke and beat Phelps by five-hundredths of a second.

"Obviously I would have liked to have a better outcome in the

200 fly," Phelps said. "I was on the receiving end of getting

touched out. Chad swam a good race. I've gotten to know him a

little over the last year. He's a hard worker, he's a tough

competitor and he's a racer."

Le Clos pounded the water when he saw the "1" beside his name.

"He has always been an inspiration to me and a role model," le

Clos said. "I've watched all his races a million times and I've

run the commentary over and over. Now, I guess I can watch my

race."

Phelps hung on the lane rope and buried his face in his hands,

disgusted with himself for having squandered what looked like a

sure gold. Le Clos won South Africa's second swimming gold of the games in a time of 1:52.96. Phelps finished in 1:53.01, while

Japan's Takeshi Matsuda took the bronze in 1:53.21.

"It's obviously my last one," Phelps said. "I would have

liked to win, but 1:53 flat isn't a terrible time. When you look at

the picture of it, it's a decent time."

But the finish was a stunner, given that Phelps had won a

memorable race at Beijing when a rival made the very same error.

Milorad Cavic of Serbia thought he had the 100 fly in the bag after

his final stroke, but Phelps made the split-second decision to get

in one more stroke and slammed into the wall -- one-hundredth of a

second ahead of Cavic.