High winds and freezing rain hit participants in the 100km (60-mile) ultramarathon in the Yellow River Stone Forest area in Jingtai, a county under the jurisdiction of Baiyin city.
Jingtai county saw a low of 6 degrees Celsius (43 degrees Fahrenheit) on Saturday excluding wind chill.
The race began at 9am on Saturday and around noon, a mountainous section of the race was hit by hail, freezing rain and gales that caused temperatures to plummet, officials from Baiyin told a news briefing on Sunday.
One runner, Mao Shuzhi, told Reuters news agency she turned around when the weather changed.
"The rain was getting heavier and heavier," said Ms Mao, who was about 24km into the race at the time and had not yet reached the mountains.
She decided to head back to her hotel but others carried on or were already in worst-hit areas.
The race was halted when some of the 172 runners went missing and a massive rescue effort was launched, with over 1,200 rescuers dispatched, assisted by thermal-imaging drones, radar detectors and demolition equipment, according to state media.
Many of the stranded runners reportedly suffered from hypothermia.
A last missing runner was found dead at 9.30am on Sunday, bringing the death toll to 21, state media reported.
151 participants had been confirmed safe.
The deaths have sparked public outrage on Chinese social media, with anger directed at the Baiyin government over the lack of contingency planning.
In a press conference on Sunday, Baiyin’s Mayor Zhang Xuchen said: "As the organiser of the event, we are full of guilt and remorse. We express deep condolences and sympathy to the families of the victims and the injured."
Additional reporting by Reuters