Australia claimed bronze as Michael Phelps farewelled Olympic swimming with another gold medal in the 4x100 medley relay.
Phelps, alongside Matthew Grevers, Brendan Hansen and Nathan Adrian, secured gold with 3:29.35, ahead of Japan (3:31.26) and Australia (3:31.58).
"Tonight is the craziest night. I dreamt about this. Looking back at my career, I've seen that I've done what I wanted," Phelps said after the relay win.
"I'm not warming down, that's for sure."
"Every Olympics has got better and better. The people have been great, the food is better. It was fun.
"I couldn't have mastered it without all of this support in my career."
USA led through Grevers in a tight first lap, ahead of Hungary and Great Britain, as Australia's Hayden Stoeckel lagged early on.
Christian Sprenger made up the yards for Australia in the breastroke as a shootout between the Americans and Japanese developed.
Kosuke Kitajima caught up to America's Brendan Hansen before releasing Takeshi Matsuda in the butterfly, just ahead of Phelps.
Phelps and Kitajima were neck and neck for much of the third stroke, before Phelps inched ahead to set finisher Adrian off for the final lap.
Matt Targett released James Magnussen for the freestyle with plenty of work to do for Australia, but Magnussen surged brilliantly to haul in Japan's Takuro Fuji over the final 50 metres.
Fuji ultimately held Magnussen off to secure silver for Japan, but the night belonged to Phelps, who celebrated with his 18th Olympic gold medal.
"[It was a] really good swim tonight by all of us," Magnussen told Channel Nine.
"[I] just wanted to get out there and have a good one for the boys and I think we did pretty well."
Magnussen said he will look back on his first Olympic experience with fond memories.
"It's been a long week but I've finished on a positive," he said.
"Everything has come so easy earlier on in my career, maybe a little bit too easy.
"It's been good to find out what it takes and now we will regroup with the coach and we will come back in four years stronger than ever.
"I didn't imagine the magnitude of it. When you are at Olympic trials or other meets, at night you go back to the hotel and you leave your day behind. Here with the village, there is no escaping the Olympic athmosphere. You are constantly surrounded by it.
"It's been super tough but it definitely prepared me for meets in the future."
Sprenger was happy with the bronze medal and said Australia's men's team will come back stronger in Rio.
"We could be a bit stronger as a team," he told Channel Nine.
"I think we did a good job. The men's team hasn't performed overly well, but I think there's good things to come as a team."
Join us Monday on FANGO for live chat, polls, trivia and more as the world's fastest man, Usain Bolt, attempts to hold onto his crown.
Olympic events on FANGO:
Monday, August 6, 3.50am: Usain Bolt and the 100m final
Wednesday, August 8, 3.50am: Sally Pearson and the 100m hurdles.
Download FANGO here.