An Oreland man was drunk and abandoned after a night of partying in Lower Gwynedd Township, and saw climbing aboard a passing school bus as his only salvation, police in the Montgomery County municipality said Friday.

Dominic Herder, 20, was taken into custody early Friday after riding the bus a few minutes to Wissahickon High School in Ambler and “following the crowd” into the school, according to Lt. Michael Gargan.

“It was just a stupid, drunk mistake,” Gargan said.

Herder was charged with trespassing on school grounds, unauthorized school bus entry, public drunkenness, and related offenses, according to court records. He was released on $5,000 unsecured bail. It was unclear whether he had hired an attorney.

Herder had been attending a house party in the township Thursday night and had stayed in the unfamiliar area for several hours, Gargan said. When it came time to leave, he realized his ride had left without him and decided to walk home in the early morning light.

While walking on Welsh Road, Herder spotted a school bus picking up students and boarded it “in hopes of getting closer to home,” according to police.

Herder rode the bus to the high school without incident. During the ride, several students took note of the unfamiliar passenger and notified administrators when the bus arrived at the school.

A school resource officer assigned to the high school approached Herder, who Gargan said had entered the building with the other bus passengers and was texting someone in hope of getting a ride home. In a statement sent to community members Friday, Wissahickon School District officials said Herder was able to enter the school because “he looked and dressed like a high school student.”

Herder fled from the officer and ran across the street to an apartment complex, where he was arrested and cooperated with police, Gargan said.

Gargan said that his department had no prior contact with Herder, who is not an alumnus of the school and spent only about 10 minutes in the building.

Herder told police said he never meant to harm anyone and was simply confused about where he was going, according to school district officials.

The high school was temporarily evacuated after Herder was taken into custody, and the district plans to conduct a review of the incident, including researching “possible solutions” to improve how students board buses and enter the building, according to the statement sent Friday.