Athletes in the marathon and race walk events at the Tokyo Olympics were contending for medals but also with an obstacle largely beyond their control -- heat wave.

While some thrived in hot and humid conditions in Sapporo, 830 kilometers to the north of the capital, many underperformed or were too exhausted to cross the finish line, including some pre-race favorites.

Athletes pour water on themselves during the men's 50-kilometer race walk at the Tokyo Olympics on Aug. 6, 2021, in Sapporo, northern Japan. (Kyodo) ==Kyodo

Olympic organizers announced in October 2019 the marathon and race walk events were moving to the cooler climes of Sapporo, the largest city on Japan's northern island of Hokkaido, to protect athletes from Tokyo's heat.

Considering the issues that athletes would later experience under the sun at Tokyo venues -- tennis world No. 1 Novak Djokovic called the humidity "brutal" and requested a schedule change -- staging some of the most grueling events of the games in a city that usually only reaches around 27 C in August seemed to make sense.

But when the International Olympic Committee made the controversial decision, which took Tokyo by surprise, they did not expect the races to coincide with the city's longest heat wave in nearly a century.

While temperatures in Sapporo are on average much lower than Tokyo, on Saturday the city registered its 18th consecutive day above 30 C for the first time in 97 years.

"(The athletes) traveled all the way up here. I'm sorry it couldn't have been cooler for them," lamented one resident.

Early Friday morning, athletes in the men's 50-kilometer race walk fought the heat by pouring water over their bodies and hanging ice packs from their necks.

Japan's Masatora Kawano was in medal contention until he pulled off the course and went to his hands and knees as if to vomit.

Of the 59 athletes who started in Sapporo Odori Park, 12 failed to make it to the finish line including world record holder Yohann Diniz of France, who dropped out the race past the halfway mark and sat down on the curb with his head in his hands.

Canada's Evan Dunfee knew how to manage the heat over 25 laps of the 2-km course and rose to the occasion, winning bronze in the event.

"I've proven in Doha that I can race in those conditions," he said, referring to the extreme heat of the world championships in 2019.

That afternoon in the women's 20-km race walk, a trio of Chinese athletes who were tapped as the biggest threats heading into the competition struggled to keep pace while Italy's Antonella Palmisano made an ally of the weather to clinch the gold medal.

"We trained three years ago in Japan -- it was much hotter than today. I like it (the temperature) very, very much," she said.

Concerned over the intense heat, organizers announced that night that the starting time for the women's marathon on Saturday would move up one hour to 6 a.m. on the advice of World Athletics' medical team, an extraordinary schedule change to make so close to a race.

The temperature started at a manageable 25 C with 84 percent humidity but the athletes kept a slow pace at the beginning, possibly wary of expending too much energy before conditions worsened. By the end some three hours later, the mercury had climbed to 29 C.

The schedule change "helped us a lot," said Peres Jepchirchir, who led a Kenyan one-two finish with world record holder Brigid Kosgei to win the gold medal.

"If we'd started at 7, by the finish after 9 it would have been too hot for us. When I heard that it was changed I was so happy. I said 'Wow, that's nice'."