(CNN) -- Nine Peruvian miners emerged into the daylight Wednesday morning after six days trapped in a collapsed mine.
State television showed the miners leaving the mine, each supported by two rescuers. They wore sunglasses to protect their eyes from the light, after spending so much time in darkness.
For days, a tube snaked down to the collapsed cavern was the only connection the miners had to the surface. It provided them with oxygen, food and water, as well as communication.
Peruvian President Ollanta Humala greeted the miners at the mouth of the mine. The group unfurled the red and white Peruvian flag and waved at television cameras.
"We are happy that this high-risk operation was successful," said Claudio Saenz, a fire department official with knowledge of the rescue efforts.
The miners had been stuck since Thursday in the wildcat Cabeza de Negro mine in southern Peru.
A cave-in over the weekend slowed rescue efforts.
It was not clear what caused the initial collapse.
Humala's government has made a push for illegal mines and miners in Peru to be formalized and regulated so that risks decrease.
After the rescue, he made a similar argument.
"This should lead us to reflect that we have to avoid these kind of risks because the results will not always be like today," he said.
Mining is big business in Peru, which is a major world producer of copper, silver, gold and other minerals.
The ordeal stirred memories of a 2010 Chilean mine collapse in which 33 men were trapped underground for 69 days. All those miners were rescued, pulled one by one from hundreds of meters beneath the Earth's surface with a specially designed capsule.