A tree branch fell on a roller coaster track at Six Flags Magic Mountain in Valencia, California, partly derailing the train and leaving riders suspended about 30 feet above the ground for more than two hours, officials said Monday.

Rescuers brought in heavy equipment to free 22 passengers on the Ninja ride, including four who suffered injuries, Los Angeles County fire officials said.

Firefighters were called to the amusement park just before 6 p.m. The last rider was pulled from the ride after sunset.

Two riders were taken to the hospital to be checked out.

According to the Six Flags website, Ninja takes riders on a winding track at speeds of 55 mph. Riders hang from the track and are swung 90 degrees each way.

"The safety of our guests and employees is our number one priority and as a precaution, the ride will remain closed until a thorough inspection of the area is complete," park officials said in a statement.