South Africa's minerals minister has ordered a six-week shut down of Elandsrand gold mine near Johannesburg after an accident had trapped workers.
The miners could only be brought to the surface in small groups
All 3,200 miners have now been rescued after a power cable accident trapped them 2.2km (1.4 miles) underground; some were stranded for 40 hours.
The mine's chairman said Wednesday's accident was a "wake-up call".
The National Union of Mineworkers (NUM) blamed the accident on poor safety and the practice of mining 24 hours a day.
"Our guys there tell us that they have raised concerns about the whole issue of maintenance of shafts with the mine, but they have not been attended to," NUM spokesman Lesiba Seshoka told the Associated Press news agency.
The miners from Elandsrand mine, 80km (50 miles) from Johannesburg, were brought out through a small shaft normally used for mining equipment. None were seriously injured.
Only 75 workers could be hauled clear at a time, adding up to no more than 300 in an hour.
Each group of miners was greeted with shouts of joy and whistling, South African Press Association (Sapa) reported.
ELANDSRAND GOLD MINE
Elandsrand mine has 6.9 million ounces of proven reserves
Located 80km (50 miles) west of Johannesburg
It has two vertical shafts - a men/material shaft and a rock/ventilation shaft
A new mine, to be finished by 2010, is being built under the existing mine, which is still in use
Harmony Gold Mining bought the mine in 2001
Minerals and Energy Minister Buyelwa Sonjica was among those who danced and sang when the last trapped miner Mandis Mandanga walked out of mine on Thursday evening.
"The mine must be closed until the shaft is repaired to give us certainty that the situation is safe," the minister told Reuters news agency after the ordeal had ended.
One of the last miners brought to safety, Richman Maneli, told AFP news agency he was happy to be out.
"It has been 30 hours of suffering," he said. "We had no food, no water and we are exhausted."
Earlier, another rescued miner, Granny Makad, told South Africa's Mail and Guardian newspaper many of the trapped miners were crying and believed they would die underground.
"It was terrible," he said. "There was not enough air and they tried putting in more and ventilating the areas where we were trapped."
The accident at the mine, owned by Harmony Gold Mining, happened at about 1000 (0800 GMT) on Wednesday morning.
Harmony chairman Patrice Motsepe said the incident was a "wake up call to all of us" and vowed to improve safety conditions.
Ms Sonjica said the government wanted to "tighten up" mine safety laws.
She also complained that she and President Thabo Mbeki had not been informed of the accident by the company and learned of it from the evening news.
The miners were trapped in a cramped space where temperatures could reach 30-40C (86-104 Fahrenheit).
A spokeswoman for the mining company, Amelia Soares, said the bottom of the shaft where they were trapped was well ventilated, and that the miners had had access to water.
The Elandsrand mine is in the Witwatersrand Basin, which holds the world's largest gold deposit.
Gold is important to South Africa's economy, says the BBC's Peter Biles in Johannesburg, although the industry has been in decline in recent years.
ELANDSRAND MINE ACCIDENT
1 45m chunk of piping breaks away near mine surface
2 It damages steelwork and severs electrical cables as it falls down the 2.2km shaft
3 Miners move from bottom of Men and Material shaft to adjacent Rock and Ventilation shaft
4 Other miners working at about 2.6km join stranded colleagues
5 They are raised to the surface via a hand-winding system