Michael Phelps secured a fairytale end to his career as an Olympic athlete as the US continued their dominance in the pool on the final night of swimming at the Rio Games.
Phelps bagged his 23rd gold medal by helping the US to victory in the 4x100m medley relay -- the last race of the competition at the Olympic Aquatics Stadium on Saturday -- reports Xinhua.
The US also won gold in the women's 4x100m medley relay while Denmark's Pernille Blume and Italy's Gregorio Paltrinieri claimed the first swimming gold medals for their respective countries at these Games.
The US team of Ryan Murphy, Cody Miller, Phelps and Nathan Adrian clocked 3:27.95, to finish 1.29 seconds ahead of Britain's Chris Walker-Hebborn, Adam Peaty, James Guy and Duncan Scott.
Australia, represented by Mitchell Larkin, Jake Packard, David Morgan and Kyle Chalmers, took bronze in 3:29.93.
Phelps began the butterfly leg with the US in second position, but he set a blistering pace to give his team the lead by the end of his 100m.
The result gave Phelps his fifth gold medal of these Games as he extended his record as the most successful Olympian in history.
Earlier, the US team of Kathleen Baker, Lilly King, Dana Vollmer and Simone Manuel won the women's 4x100m medley in a time of 3 minutes 53.13 seconds, 1.87 seconds ahead of Australia. Denmark took bronze in 3:55.01.
Australia's team comprised Emily Seebohm, Taylor McKeown, Emma McKeon and Cate Campbell while Mie Nielsen, Rikke Moller Pedersen, Jeanette Ottesen and Pernille Bloom represented Denmark.
It was the sixth consecutive occasion that the US and Australia have occupied the first two places in the event at the Olympic Games.
The US' two victories on Saturday gave them 16 out of a possible 32 swimming gold medals here.
Blume won Denmark's first gold medal in any event at the Rio Games by storming to victory in the women's 50m freestyle.
The 22-year-old finished in 24.07 seconds, just two hundredths of a second ahead of Simone Manuel of the US. Belarus swimmer Aliaksandra Herasimenia took bronze in 24.11 seconds.
Blume had never previously claimed an Olympic medal, despite winning three world championship titles.
Her time fell just short of the Olympic record of 24.05 seconds set by Dutch swimmer Ranomi Kromowidjojo at the London 2012 Games.
Manuel became the first Afro-American individual swimming gold medallist when she won the 100m freestyle on Thursday. The 20-year-old was also part of the USA's 4x100m freestyle relay team that claimed the silver medal on August 6.
Paltrinieri, 21, coasted to victory in the men's 1500m freestyle, touching the wall in 14 minutes, 34.57 seconds, 4.91 seconds ahead of the USA's Connor Jaeger. Paltrinieri's fellow Italian Gabriele Detti took the bronze medal in 14:40.86.
Paltrinieri, the 1500m gold medallist at last year's world championships in Russia, led from the outset and swam under world record pace for much of the race before easing off in the final laps.
China's world record holder and defending champion Sun Yang failed to qualify for the 1500m final.