Chile's president euphorically waved the note, written deep inside a collapsed mine, that his country waited 17 agonizing days to see: "All 33 of us are fine in the shelter," one of the trapped miners wrote in red letters.

Authorities and relatives of the miners hugged, climbed a nearby hill, planted 33 flags and sang the national anthem Sunday after a probe sent some 2,257 feet (688 meters) deep into the mine came back with the note. "Today all of Chile is crying with excitement and joy," President Sebastian Pinera said.

The miners' ordeal may have just begun: Rescuers say it could take four months — until around Christmas — to get them out.

The men already have been trapped underground longer than all but a few miners rescued in recent history. Last year, three miners survived 25 days trapped in a flooded mine in southern China, and two miners in northeast China were rescued after 23 days in 1983. Few other rescues have taken more than two weeks.

For the moment, however, news that the men even survived an Aug. 5 tunnel collapse outshines all other details.

A video camera lowered down the probe shaft showed some of the miners, stripped to the waist in the underground heat, waving happily. But they weren't able to establish audio contact, Pinera told reporters at the scene.

"I saw eight or nine of them. They were waving their hands. They got close to the camera and we could see their eyes, their joy," Pinera said.

Word of the miners' survival was a rush of good news in a country still rebuilding from a magnitude 8.8 earthquake Feb. 27 and its resulting tsunami, which together killed at least 521 people and left 200,000 homeless.

"I am OK thanks to God. I hope to get out soon," wrote one of the trapped miners, Mario Gomez. "Patience and faith. God is great and the help of my God is going to make it possible to leave this mine alive."

Gomez, 63, appeared to be aware that it will take a long time for rescuers to reach him and his fellow miners. "Even if we have to wait months to communicate. ... I want to tell everyone that I'm good and we'll surely come out OK," he said.

Mine officials and relatives of the workers had hoped the men reached a shelter inside the mine when the tunnel collapsed the San Jose gold and copper mine about 530 miles (850 kilometers) north of the capital, Santiago. But they had said air and food supplies would only last 48 hours.

Rescuers drilled repeatedly in an effort to reach the shelter, but failed seven times; they blamed the errors on the mining company's maps. According to Gomez's note, at least some of those probes were close enough that the trapped miners heard them.

Rescuers' hopes rose after the eighth attempt early Sunday when they heard hammering sounds. They sent down a probe, then pulled it up with two notes the trapped miners had placed inside, including the short one Pinera read. Gomez wrote the other note to his wife, confirming the miners' location underground and saying he loved her.

Liliana Ramirez couldn't believe it when Chile's mining minister said her husband had sent a note to his "Dearest Lila."

"I know my husband is strong, and at 63, is the most experienced miner who could lead his co-workers," she said. "But no more mining (for him.)"

Gomez wrote that the miners used vehicles for light and a backhoe to dig a canal to retrieve underground water.

The opening the miners used to deliver the notes is not wide enough to haul up the miners. Rescue equipment brought from outside the country was being assembled Sunday to dig a tunnel 27 inches (68 centimeters) in diameter through which the miners will eventually be brought to the surface.

The hole already drilled will be used to send down small capsules containing food, water and oxygen if necessary, and sound and video equipment so the miners can better communicate with loved ones and rescuers.

This spring 115 Chinese miners were rescued after being trapped for more than a week because workers digging tunnels had broken into a water-filled abandoned shaft. The accident killed 38 miners.

Chile's drama months after the earthquake shares some parallels with the 2002 Quecreek Mine accident, in which nine Pennsylvania miners were trapped in a flooded tunnel about 15 miles from where one of the planes hijacked on Sept. 11 crashed some 10 months earlier. Americans cheered as all nine miners were rescued three days later.

Hundreds of workers are using equipment from the United States and Australia in the Chilean rescue.

Both the company that owns the mine, San Esteban, and the National Mining and Geology Service have been criticized for allegedly failing to comply with regulations. In 2007, an explosion at the San Jose mine killed three workers.

Chile is the world's top copper producer and a leading gold producer.