CHICAGO (CBS) — A Southwest Airlines flight headed to Chicago was forced to return to Oakland, California, and make an emergency landing on Wednesday, due to a landing gear problem.

Southwest Airlines Flight 2547 took off from Oakland International Airport around 8 a.m. Chicago time, carrying 139 passengers. It was scheduled to arrive in Chicago around noon, but the pilot turned the plane around after takeoff because of a maintenance issue, according to the airline.

The Federal Aviation Administration said the plane returned to Oakland due to a landing gear problem.

The plane circled the airport for a few hours to burn off fuel before attempting an emergency landing at about noon Chicago time. The plane landed safely at about 12:15 p.m.

CBS San Francisco reports passengers on the flight knew almost immediately after takeoff that something was wrong. Originally, they thought it was an engine issue that the pilot thought could be resolved in a matter of minutes.

But it turned out to be much more serious. When the landing gear was being brought up after takeoff, some passengers saw sparks. The pilot then tried to bring the gear back down, but it wasn’t working.

Instead of continuing to Chicago, the pilot flew the Boeing 737 for four hours trying to burn off the majority of the 12,000 gallon fuel tank.

A passenger told KPIX 5 she was extremely nervous the whole time she was in the air.

“The worst part was the beginning because no one would tell us anything,” said Flight 2547 passenger Ashley Stasio. “Oh, I thought I was going to die. People were really scared. It made me feel good because the fact that it was such an emergency, they had a lot of backup and we’re all safe.”

Stasio said that before they descended passengers were told to brace themselves, but the landing went smoothly. People were clapping, cheering and crying as the plane came to a stop.

Southwest later released a statement that said in part “our Oakland employees are working to get our 139 customers to their destinations. The aircraft will be taken out of service and inspected.”

“With everything we do, safety is of paramount importance and we appreciate our Customers’ patience while we work to get them to their destinations for the holidays,” Southwest spokesman Dan Landson said in an email.