The boy emerged from the hole in the arms of a soldier after army rescuers had burrowed through after digging a hole parallel to the one the boy, known only as Prince, fell into on Friday.
Hundreds of anxious onlookers erupted in cheers and applause as he was brought to the surface wrapped in a white sheet, and well-wishers held up a pink poster that read "Happy Birthday Prince".
The rescue operation had continued amid fears that the sandy soil could cave in on the child at any moment.
A closed-circuit camera lowered into the hole had earlier shown him looking bewildered and munching on chocolate and drinking milk that had been lowered by rope, along with biscuits and tea made by his mother.
Oxygen had been pumped into the pit - only 300cm in diameter -and rescuers had chatted with the boy to keep up his morale.
He had fallen down the narrow hole, which had been left uncovered by construction workers, while was playing and was found hours later when villagers heard him crying. He is believed to be uninjured.
The drama in the village of Aldeharhi villa in Haryana state has captivated India, with politicians travelling to the scene, television channels running rolling coverage of the story and thousands of people sending news stations mobile phone text messages offering hopes for a quick rescue.
Special prayers have been held in Hindu temples, Muslim mosques, Christian churches and Sikh places of worship cross the country.
Manmohan Singh, India's prime minister, was among those moved by the boy's story.
"The prime minister prays for the speedy rescue and good health of the young boy who has been trapped," an official told the Press Trust of India news agency on Sunday.
"We will take full medical care of the boy on his rescue," he said.
Army engineers were called in after local police failed to extricate the boy from the hole.