Two dogs made it home safely after spending nearly a week alone in the Gifford Pinchot National Forest thanks to two hikers.

Dennis Elton drove into the forest near Mt. St. Helens on Oct. 26 with his dogs, a Brittany spaniel named Woody and a chocolate lab named Brock. When the dogs got out of the truck, they caught a scent and ran off, Elton recalled.

"I looked for them for hours," said Elton, according to USA Today. "I'd never left a dog in the woods before."

Elton's family posted pictures of the companions on social media and Craigslist following their disappearance, while Elton himself spent the next six days searching for the dogs in the forest without any luck.

"He spent $500 on gas and drove hundreds of miles," said Elton's wife, Shawn. "We were all heartbroken."

However, Elton's luck soon turned around the next Sunday. Two hikers had found the dogs at separate points on the trail, each about 25 miles from where the dogs had run off to the week before, NBC's Portland affiliate KGW-TV reported.

Corey Theisen found Woody while hiking with friends and said that the dog was cold, wet and scared.

"I was thinking how am I going to help this dog?" said Theisen. "So I took a couple pictures of him and I posted them online and I asked all my Facebook friends to help me."

The story was shared more than 9,000 times and eventually made its way to Elton.

"I said that's Woody! That's Woody!" said Elton. "I stood up on the edge of my bed and said, where is he?"

After Elton picked Woody up from Theisen's home in Portland, Ore., he got a phone call from his wife saying someone else had found Brock and posted pictures of him on social media, according to the Daily Mail.

Nick Gibson found Brock while hiking near Lava Canyon and brought the chocolate lab to his home in Camas before getting a hold of Shawn.

"She started telling me the story about the other dog and everything and it just sort of blew me away," said Gibson.

Dennis drove both dogs back to his home in Amboy, Wash., thankful for everyone who had helped and grateful that the dogs were still alive.

"They went 25 miles," said Elton. "I don't know how they got through this."