Chile's president has said his country will never be the same again after the extraordinary rescue of the 33 miners trapped deep underground for 69 days.
Sebastian Pinera said he thought Chile was "more united and stronger than ever", and "more valued" worldwide.
There were earlier ecstatic scenes as Luis Urzua, 54, the last miner out, emerged at the top of the rescue shaft.
The 22-hour operation saw each man being winched up in a narrow capsule. They have now been taken to hospital.
Some have severe dental infections, and others have eye problems as a result of living in the dirt and darkness of the mine. One has been diagnosed with pneumonia but his condition is not thought to be serious.
Health Minister Jaime Manalich nevertheless stressed that all appeared to be in far better condition than expected. No-one has survived as long trapped underground.
The miners were left with only 48 hours' worth of rations when part of the San Jose copper and gold mine in Chile's Atacama desert collapsed on 5 August. After 17 days of drilling, rescuers made contact.
President Pinera was waiting at the head of the 624m (2,047ft) rescue shaft at 2155 on Wednesday (0055 GMT on Thursday), when the capsule carrying Mr Urzua emerged to jubilant cheers, songs and applause. Rescuers quickly wrapped him in the flag of Chile.
Thirty-three balloons in Chilean colours were released above the mine.
Mr Urzua, the shift supervisor at the mine who has been credited with helping the miners endure the early days of their ordeal, then embraced the president and said: "We have done what the entire world was waiting for.
"We had strength, we had spirit, we wanted to fight, we wanted to fight for our families, and that was the greatest thing."
Describing him as a "great captain", Mr Pinera replied: "You are not the same, and the country is not the same after this. You were an inspiration. Go hug your wife and your daughter."
He then led the crowd in singing the Chilean national anthem. Watching the rescue on a big screen nearby, the miners' friends and relatives were showered with champagne and confetti.
Six rescuers who were lowered into the mine to supervise the operation held up a banner saying "Mission accomplished."
The last of them, Manuel Gonzalez - who was also the first rescuer to go down the shaft - returned to the surface just under two-and-a-half hours later. Before leaving the underground chamber, he turned to a video camera, bowed and waved in triumph.
Relatives of the freed men climbed a hill where 33 Chilean flags were flying, one for each miner, to give thanks for the rescue.
The sister-in-law of oldest miner Mario Gomez, Belgica Ramirez, told the AFP news agency: "It's a new life about to begin."
In a televised address to the nation at the mine entrance, Mr Pinera said: "The miners are not the same people who got trapped on... 5 August. They have come out stronger, and they taught us a lesson. But Chile is not the same either.
"I think Chile today is more united and stronger than ever, and I think Chile today is more respected and more valued in the whole world.
"What ended up as a real blessing from God started as a possible tragedy. But the unity, the faith, the compromise, the honesty, the solidarity of the Chileans in those 69 days makes us very proud," he added.
The 33 rescued miners are now being treated in two wards at the hospital in nearby Copiapo. The rooms have been darkened to allow the men to adjust to the light.
The BBC's Rajesh Mirchandani, outside the hospital, says the eldest miner, Mario Gomez, 63, is being treated for pneumonia and the lung disease silicosis. The second man out of the mine, Mario Sepulveda, also has silicosis.
Our correspondent says that doctors will want to ensure the men are fit and well before they go home, but it is possible some may leave the hospital as early as Thursday.
The health minister, Mr Manalich, confirmed some might go home earlier than predicted, but added that several of the miners had been unable to sleep, were anxious or simply wanted to talk to relatives.
One doctor, Guillermo Swett, told the Associated Press news agency that the youngest miner, Jimmy Sanchez, 19, was struggling and appeared depressed.
"He spoke very little and didn't seem to connect," Dr Swett said.
Our correspondent says there was an incredible atmosphere in the main square in Copiapo as crowds watched the final man leave the mine. Afterwards many people drove their cars around town honking the horns.
The rescue operation began shortly after 2315 on Tuesday (0215 GMT on Wednesday) with Manuel Gonzalez being lowered down the shaft.
Mr Gonzalez was supposed to return to the surface and report on the condition of the rescue shaft, before handing over to a paramedic. However, the miner Florencio Avalos instead got into the capsule and was hauled up.
The miners wore a "bio-harness" designed for astronauts - which monitors their heart rate, breathing, temperature and oxygen consumption - and sunglasses to protect their eyes from the glare of the desert.
Mr Avalos reached the surface at 0010 on Wednesday (0310 GMT) and was greeted by his family, rescuers and President Pinera.
The rescue team was soon able to cut the time down between each ascent from an hour to 25 minutes, and by Wednesday afternoon it became clear that the operation would be completed in half the time originally estimated.