There was the dreaded Zika virus. There was pollution. There was poor infrastructure at the Games village. And then there was the Russian doping scandal. The Rio Olympics was all but written off. But Michael Phelps was there at Rio. So was Usain Bolt. Like Phelps, Rio was going to be his last Olympics. At 29, would he be able to achieve the unprecedented feat — the Triple Triple. And what about the charismatic Mo Farah? Bradley Wiggins was there too — he had a point to prove.

But would these stars shine given the odds? Michael Phelps at 31 proved that he was still the king of the pool. He increased his individual gold medal tally to 13, beating a 2,168 year record held by Leonidas of Rhodes who has 12. Phelps said goodbye — adorned with 23 gold, three silver and two bronze medals, a total of 28, making him the most decorated Olympian.

Bolt bade goodbye at Rio too but not before achieving the Triple Triple. No athlete before him had won the 100, 200 and 4x100 metre golds in three successive Olympics. Mo Farah became the first man in 40 years to retain the two Olympic distance, the 10,000 and 5,000 metre crowns. Finland’s Lasse Viren, did the double at the 1972 and 1976 Games. Bradley Wiggins became the first Briton to win eight Olympic medals with a win in the team pursuit in a new world record time. He has five golds, one silver and two bronzes surpassing fellow cyclist Sir Chris Hoy’s seven medals.

In the women’s 5,000-metre heat, Abbey D’Agostino of the US and New Zealand’s Nikki Hamblin were involved in a fall. They were strangers. D’Agostino helped Hamblin up, encouraging her to finish the race. D’Agostino tore a knee ligament in the fall and couldn’t finish. Hamblin came last. Neither won a medal. But the Olympic spirit had won. It was a golden Olympics for couples as well. Britons Laura Trott and Jason Kenny will marry in September. Trott became Britain’s most successful female Olympian with her fourth gold in the omnium and Kenny equalled Chris Hoy’s record of six golds by winning the keirin. American Ashton Eaton won the gold in decathlon, while his wife, Brianne Thiesen-Eaton, a Canadian, won bronze in the heptathlon.

The old order must give way to the new. Joseph Schooling beat his hero Michael Phelps in the 100-metre butterfly. Simone Biles mesmerised in gymnastics and Katie Ledecky emerged a champion like her idol Michael Phelps. Brazil won the football gold. And as Brazil celebrated the victory, the world celebrated sport. It celebrated Rio. The spirit of the Olympics had struck gold yet again.