ISTANBUL—A commercial plane 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.

Some of the 168 people on board the Boeing 737-800 described it as a “miracle” that everyone was evacuated safely.

Images show the aircraft on its belly and at an acute angle just above the water. If it had slid 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 on board Pegasus Airlines Flight PC8622. The six-member crew, including two pilots, was also evacuated and Pegasus said there were no injuries. Flights were suspended at Trabzon Airport for several hours after the incident before resuming again Sunday.

Passenger Yuksel Gordu told Turkey’s official Anadolu news agency that words weren’t enough to describe their fear.

“It’s a miracle we escaped. We could have burned, exploded, flown into the sea,” Gordu said. “Thank God for this. I feel like I’m going crazy when I think about it.”

Another passenger, Fatma Gordu, told private Dogan news agency that there was a loud sound after landing.

“We swerved all of a sudden,” she said. “The front of the plane crashed and the back was in the air. Everyone panicked.”

Trabzon Gov. Yucel Yavuz said that investigators were trying to determine why the plane had left the runway. The prosecutor’s office launched an investigation.

The flight originated in the capital, Ankara.