Eight Houston students were trapped for hours on a roller coaster in Galveston Thursday evening, prompting a meticulous rescue operation to bring them down from nearly 100 feet in the air.

The group, made up of middle school and high school students, got stuck on the Iron Shark roller coaster at Galveston Island Historic Pleasure Pier after the nearly-100-foot-tall ride malfunctioned at around 5 p.m. Thursday. The fire department showed up around 5:30 p.m. to rescue them, Galveston Fire Chief Mike Varela Jr. said in a Thursday evening news conference. 

Local news footage shows the students stuck in a roller coaster car just beyond the ride’s peak, at the start of a steep drop. They were strapped into their seats and tilted toward the ground.

Galveston firefighters used a massive ladder truck to get to the students at the top. They extracted them one-by-one using a safety harness, the fire department said. The operation took hours, with 20 minutes between rescuing each of the students, according to KHOU 11, a Houston news station.

The ride experienced a malfunction during its initial ascent, said Terry Turney, the chief operating officer of Pleasure Pier.

“As designed, it immediately stopped to keep everyone safe. Our focus immediately shifted to the safety of our eight guests,” Turney said in a statement to Houston-area media.

“A thorough inspection of the ride will take place before it is placed back in service,” he added.

The Iron Shark ride goes 52 miles per hour and features a 100-foot lift and drop, according to Pleasure Pier’s website. Riders must be at least four feet tall.

Varela said the rescue crew was “ready to go” after being trained to handle situations like this.

“Once they made it up there, they were able to use their skills to calm everyone down, reassure them that the equipment they were going to put on them was gonna keep them safe,” he said at the news conference.

“We are grateful that all students, staff and chaperones are safe. School administration is in direct contact with the families of the eight students who were on the trip,” the district said in a statement Friday. “We are thankful for the rescue efforts of the first responders and park personnel.”

Pleasure Pier, which opened in 2012, is a major Galveston tourist attraction with amusement rides, midway games, shops and restaurants. It juts out into the Gulf of Mexico in Galveston.