ISTANBUL -- A commercial airplane that skidded off a runway after landing in northern Turkey dangled precariously off a muddy cliff with its nose only a few feet from the sea.

Images show the Boeing 737-800 on its belly and at an acute angle just above the water. If it had stopped any further along the slope, the plane would have likely plunged into the Black Sea in the Turkish province of Trabzon.

The incident late Saturday created panic among the 162 passengers and crew on board the Pegasus Airlines flight. The airline said in a statement that all those on board disembarked safely.

A Boeing 737-800 of Turkey's Pegasus Airlines after skidding off the runway downhill towards the sea at the airport in Trabzon, Turkey, Sunday, Jan. 14, 2018. AP

Trabzon Gov. Yucel Yavuz said Sunday that investigators were trying to determine why the plane had left the runway and that the airport would be closed until 8 a.m. local time.

Get Breaking News Delivered to Your Inbox

The state-run Anadolu news agency said panic broke out on board as the plane careened out of control, BBC News reports. Photos showed the jet lying nose down just feet from the water's edge on a muddy slope.

"We tilted to the side. The front was down while the plane's rear was up. There was panic, people shouting, screaming," passenger Fatma Gordu told Anadolu news agency.

Another passenger, Yuksel Gordu, said words weren't enough to describe the fear on the flight, which originated in Ankara, the capital.

"It's a miracle we escaped. We could have burned, exploded, flown into the sea," Gordu told the news agency. "Thank God for this. I feel like I'm going crazy when I think about it."