A seven-year-old Japanese boy was missing for six days after being abandoned in a forest by his parents has been found alive. Yamato Tanooka was discovered at a Japanese military base about two miles from where he disappeared. (Reuters)

The 7-year-old boy lost in a bear-inhabited forest in northern Japan for six days has been found alive and relatively well, according to local reports.

Yamato Tanooka was found by chance at about 7:50 a.m. Friday, curled up on a mattress inside a hut on a former Japanese air force base on the northern island of Hokkaido. The base is about three miles from the site where his parents abandoned him as punishment the previous Saturday.

The boy was in relatively good health, according to public broadcaster NHK, with mild dehydration and hypothermia. He had scratches on his hands and legs but no other injuries.

“A self-defense forces official who was on a drill found a boy whose age appeared to be seven,” the Agence France-Presse news agency quoted a police spokesman as saying. “There was no conspicuous external injury, and the boy introduced himself as Yamato Tanooka.”

The boy told police he had been in the hut for several days after walking through the forest by himself, according to Kyodo News. He didn't have any food but had been drinking water from a tap outside the hut, and was ravenous.

Police officers and members of the Ground Self-Defense Force conduct a search operation for Yamato Tanooka, a 7-year-old boy who has been missing since May 28, in a forest at Nanae town, in Japan's northernmost main island of Hokkaido Thursday, June 2, 2016. (Daisuke Suzuki/AP)

He was given rice balls and a drink, and was air-lifted to a hospital in the city of Hakodate for a medical checkup. There, he was put on an intravenous drip to rehydrate.

Hopes had been fading rapidly after six days passed without any sign of the boy, who was wearing light clothing and had no food with him. A huge search involving military personnel had been underway in the forest, thought to be home to about 500 brown bears, but the effort was hampered by heavy rain.

The boy had been foraging for wild vegetables in the forest with his parents last Saturday. He had apparently been throwing rocks at cars, so his father left him on the side of a mountain road to punish him. But when the family returned a few minutes later, the boy was nowhere to be found.

His parents initially told police they had lost him while walking in the forest but soon confessed to the punishment, eliciting sharp criticism in Japan.

Takayuki Tanooka, the boy's father, acknowledged to reporters on Friday that he had “gone too far” in abandoning his son, and said he had apologized to him.

“The first thing I said to him was that I was really sorry. He nodded and said okay, like he understood,” his tearful father told TV Asahi.

"First of all, it's really great he is safe," he continued. "I can't find the words. It's good."