MARTINEZ -- Two horses that wandered from their enclosure wound up on an Interstate 680 onramp early Monday morning, officials said.

Their timing was excellent. Only the lack of traffic along the freeway shortly after 2 a.m. prevented the outing from becoming tragic, a California Highway Patrol officer said.

Both horses were eventually rescued and unharmed.

"You never know what you're going to get on the freeway," CHP Officer John Fransen said. "It's one of the reasons why we encourage people not to drive distracted. In this case, it's horses. Another time, it's camels. So that's why it's imperative to pay attention."

The strange scene happened on the northbound direction near the Pacheco Avenue onramp around 2:06 a.m. after several motorists called the CHP to report the horses, CHP Officer John Fransen said. The CHP shut down the onramp at 2:19 a.m. and kept it closed until almost 4 a.m., Fransen said.

A witness helped officers from the Contra Costa County Animal Services Dept. to escort the horses from the ramp, Fransen said. It was not immediately known if the person who helped was the owner of the horses or how far they had wandered, Fransen said.

Calls to the animal services department went unreturned Monday.

The sighting came less than a month after a camel wandered onto Bailey Road, a major road that traverses the hills between Concord from Pittsburg.

Rick Hurd covers public safety. Contact him in Walnut Creek at 925-945-4780 and follow him at Twitter.com/3rdERH.