Michael Phelps won the 19th gold medal of his Olympic swimming career on Sunday after helping the US men’s team to victory in the 4×100 metres freestyle relay.

The 31-year-old, making his first competitive appearance in the pool at his fifth Games after sitting out the heats, now has an unprecedented 23 medals with two silvers and two bronzes filling out his tally.

Phelps, the most decorated Olympian of all time, produced a stunning second leg to inspire the United States to victory in the 4x100m freestyle relay.

b’Phelps celebrates the victory | Source: AFP’

The 31-year-old — who has now won 19 gold medals, 23 overall — roared with delight and hugged his team-mates after they came home ahead of defending champions France.

It was a fairytale moment for Phelps, who came out of retirement for one last crack at the Olympics after battling his personal demons during a stint in rehab.

London 2012 champions France took the silver medal and Australia the bronze.