BEIJING — Four miners have emerged alive after 36 days trapped 720 feet underground in eastern , after a huge, intensely reported rescue effort in this country that has been plagued by mine disasters.

Hundreds of rescuers who had drilled a shaft to the miners and kept them alive cheered and clapped Friday night as the first man winched to the surface weakly raised his arm. Several failed recovery attempts before this one had brought the trapped men to despair.

The third miner lifted to the surface yelled “Thank you” after he came up, , Shandong’s main state-run news website, reported on Saturday. The rescued men were rushed to a local hospital, accompanied by a crush of reporters and cameras but too weak to speak about their ordeal.

The four men were among 29 miners caught when a cavernous gypsum mine in Pingyi County, Shandong Province, collapsed on Dec. 25. Eleven were rescued soon after, and one was found dead. The mine’s principal owner, Ma Congbo, two days after it collapsed, drowning himself in a well, state-run media reported.

Interactive Feature | A Year of Disasters in China A landslide in Shenzhen, China, which destroyed 33 buildings and buried dozens of people under excavated dirt and construction waste, was the latest in a string of deadly disasters linked to human error or activity in China this year.

Thirteen miners were still unaccounted for Saturday. The government has said that it will keep searching for them, although hopes that they remain alive appear to be faint.

“In all my 30 years doing this, this was the most trying and the most difficult rescue,” said Du Bingjian, a mine disaster expert who was brought in to help.

The rescuers drilled a new shaft to retrieve miners deep below the surface, rather than clearing shafts already in place, following an innovative technique used to save 33 miners in 2010 and in 2002, .

But there were many setbacks before the triumph.

At first, the rescuers were unsure whether anyone had survived underground after the mine tunnels tumbled down and flooded. But after five days of drilling exploratory holes, they established contact with the trapped men and to send down food, medicine and other supplies, and to keep in phone contact.

The men huddled in an area of , where they subsisted on milk, water and bread made from rice, sorghum and peanuts, meanwhile fearing that fresh collapses or flooding could kill them.

“Shelter in a safe place,” a rescuer on the surface told them, according to . “First drink your milk, keep healthy, and sooner or later we’ll be able to rescue you.”

But several attempts to drill a wider shaft to haul the men out failed, as drills failed or tumbling earth and flooding choked off the holes, which had to pass through difficult, crumbly sandstone and limestone. As days turned into weeks, the miners thought they would die entombed in the mine, said Mr. Du, the rescue expert.

“They were all wondering whether up on the surface we’d give up on rescuing them,” he said, according to China National Radio. “When we called, they’d cry, and down in the mine you could hear the sound of howling and wailing.”

As a month of entrapment approached, the men told the rescuers: “Tell it to us straight, we know that there’s no hope of rescue.”

But about a thousand police officers, government workers and other rescuers on the surface kept trying. They sent down video of their operation to reassure the men that they had not been forgotten. They also passed down playing cards.

Over the past decade, the Chinese government has sought to reduce the nation’s vast annual death toll from mining accidents, with considerable success. In 2002, there were 7,000 deaths in coal mines alone; by 2014, fatalities in mines of all kinds had fallen to somewhere over 1,300, according to incomplete government statistics.

As public ire about the perils of China’s mines has grown, so has the amount of media attention devoted to rescues, and reporters gathered in Pingyi to .

A week ago, engineers succeeded in drilling a shaft close to the miners. But an accumulation of mud and rocks still lay between the men and their potential rescue. The engineers sent down drills, picks and other tools, and asked the miners to help clear the passage. By Friday night, the engineers decided that the shaft was safe enough to attempt a rescue.

The trapped men — Zhao Zhicheng, Li Qiusheng, Guang Qingji and Hua Mingxi — were lifted one by one to the surface in a harness, each greeted by a burst of camera flashes after more than 860 hours deprived of sunlight. To protect their eyes, they were blindfolded, and on Saturday they were recovering in the hospital, where doctors said they were in stable condition.

The four survivors are “mentally alert, and there is hope that they can leave hospital before the Spring Festival,” , referring to the Lunar New Year holiday that starts on the eve of Feb. 7.