A man who helped injured victims in the aftermath of a deadly earthquake in China's Sichuan province and was stranded on the mountainside for 17 days has finally been rescued.

He was found Wednesday after a villager spotted him lying under some trees wearing tattered clothes and with injuries on his legs.

Gan Yu, a worker at the Wandong hydropower station in Sichuan's Luding county, was on duty on Sept. 5 when the 6.8-magnitude quake struck. The earthquake claimed a death toll of at least 93 people, China Daily reported.

Gan and his coworker, Luo Yong, provided first aid to injured colleagues and helped prevent flooding by opening a dam's floodgates after the earthquake.

The two coworkers eventually tried to leave the mountainside and walked around for 12 miles but had no success. They also tried to get the attention of rescuers.

"We took our clothes off, strung them on tree branches and waved them around," Luo told China National Radio (CNR), according to News 18.

The pair decided that Luo would go searching for help while Gan, who is severely short-sighted and lost his glasses during the earthquake, stayed put.

After making a bed of moss and bamboo leaves, Luo left Gan behind with some wild fruit and bamboo shoot.

A helicopter crew spotted Luo after he lit up a fire in an empty village. He was rescued on Sept. 8.

Luo provided details about Gan's location, but by the time rescuers arrived at the spot on Sept. 11, Gan was no longer there. Only his footprints and discarded clothes were found.

Ni Taigao, a villager who was familiar with the hill of Menghugang, heard about the rescue operations launched to find Gan and decided to join in. The villager began hiking Wednesday morning carrying two bottles of water and some food.

In a couple of hours, heard cries for help coming from the woods. Ni followed the voice to find Gan and soon informed the authorities.

"He looked fine, but he cried a lot when seeing me and said it was good that he met me," Ni said, according to South China Morning Post.

Gan was rescued and eventually taken to a local hospital. He is reportedly in stable condition.

Luo was happy to hear the news about Gan's rescue.

"I lost my phone and did not have his number, I was trying to find a way to contact him. I want to see him," he said, as per the outlet.

Gan said he managed to stay alive on the mountainside for 17 days by surviving on fruits and water.

The man's rescue is a "miracle of life," Ni reportedly told CNR.