A deputy discovered a five-month-old boy buried alive for at least nine hours under sticks and forest debris in the Montana wilderness, officials said Tuesday.

The Missoula County Sheriff’s Office said in a statement that a deputy heard a faint cry coming from an infant, “followed the sound,” and discovered the five-month-old alive and buried with his face down under a pile of sticks:

Police said the baby had been wearing a soiled onesie and had been out in the wilderness for at least nine hours. When the deputy found him Saturday night, it was 46 degrees.

The Sheriff’s Office said authorities went searching for the baby after receiving a report of a man acting erratically and threatening people in the Lolo Hot Springs area in Montana’s Lolo National Forest at 8 p.m. on Saturday.

When authorities arrived in the area, they received more reports about the man claiming to have a gun in his possession.

Once deputies were able to track down and question the man—who appeared to be under the influence of drugs—he revealed to authorities that the five-month-old had possibly been buried in the mountains.

Deputies and officers from different departments, including several Search and Rescue officials and the United States Forest Service, formed a search party to look for the baby in the woods.

Authorities found the infant and took him to a local hospital, where he was treated for minor scrapes and bruises and is in good condition, Missoula County Sheriff’s Office spokeswoman Brenda Bassett said in a statement.

“For all of us at the sheriff’s office, this is what we call a miracle,” police said. “For the officers who were present for this event, it’s especially hard knowing what this small baby endured in the last 24 hours.”

Police arrested Francis Carlton Crowley, 32, and charged him with criminal endangerment. Crowley is currently being held on $50,000 bond. The Sheriff’s Office announced that he will appear in court on Tuesday and may face additional charges.

The child is now in the custody of the state’s Division of Child and Family Services.