The seven-year-old Japanese boy abandoned in a forest by his parents for being naughty meant to follow his parents' car but was crying so hard he went the wrong way, a newspaper said.
Feeling that the woods were "scary", Yamato Tanooka kept walking along the road even after the sun set, eventually arriving at a military base where he found an unlocked building and slipped in.
The massive search for Yamato Tanooka, after his parents left him by the side of a road in northern Japan as discipline for throwing stones at cars, kept Japan riveted for nearly a week until his discovery on a Japanese military base.
It prompted a flood of social media comment, much of it critical of the parents, but police said on Monday that they would not file charges.
The Mainichi Shimbun newspaper said on Monday he was sobbing so hard he took the wrong direction.
"I walked for about five hours, I think," Yamato was quoted as saying. After finding the building, "I was cold so I went inside to sleep."
Wearing a baseball cap and holding a paper baseball, Yamato waved at journalists and well wishers gathered in front of the hospital on Tuesday, occasionally flashing a gap-toothed smile.
Asked how he was feeling, the boy said: "I'm all right." He added that he was looking forward to getting back to school as his father took his hand and led him to a car.
Yamato's parents first said he disappeared while they foraged for edible plants, but later told police they had left him by the road to discipline him after he threw stones at people and cars.
They said when they drove back a few minutes later the boy had disappeared.
Yamato said he stayed in the unlocked building for the next six days with no food, although he drank water from an outdoor tap. Although he heard search helicopters flying overhead, he decided to stay where he was and await discovery, media said.