Two hijackers diverted a domestic flight from Libya to the Mediterranean island of Malta on Friday and threatened to blow it up with hand grenades.
After hours of negotiations, the standoff ended peacefully with the hijackers freeing all 117 passengers and crew and walking off the plane to surrender.
The hijacked Airbus A320 flight, operated by Afriqiyah Airways, was travelling from the Libyan oasis city of Sabha to Tripoli when it was diverted to Malta and landed at 11:34 a.m. local time.
Malta state television TVM said the two hijackers had hand grenades and had threatened to explode them.
All flights to Malta International Airport were immediately diverted and emergency teams including negotiators were sent to the airport tarmac.
Ali Milad, the pilot, told Libya Channel TV network that initially the hijackers had asked him to head to Rome but Malta was much closer.
Malta's prime minister, Joseph Muscat, told reporters the hijackers wanted negotiators to go on board but his government refused and insisted that all passengers and crew be released.
The hijackers then allowed the plane's doors to open at 1:44 p.m. and a staircase was brought over to let freed passengers disembark in groups.
In a series of tweets, Muscat said 65 people were allowed to leave, then another 44 were freed, including some crew, all coming out without hand luggage.
Finally the hijackers walked off the plane with the final crew members, including the pilot and co-pilot.
Muscat announced that the hijacking was over in a tweet at 3:44 p.m., saying the two Libyan hijackers surrendered without making any conditions.
They were searched, taken into custody and being questioned.
The airline said that 117 people, including six crew members, had been on board the hijacked plane.
Muscat said the two hijackers had a hand grenade and a pistol on them and a second pistol was found on the plane during search by Maltese soldiers.
Milad, the pilot, identified the two hijackers as Moussa Shaha and Ahmed Ali of Libya, who other Libyan officials said were in their twenties.
The pilot said the men were seeking political asylum in Europe and wanted to set up a political party called "the New Fateh." Fateh is a reference to former Libyan dictator Moammar Gadhafi, who led the Fateh revolution after his coup in 1969.
After many hostages left the plane Friday afternoon, one of the hijackers waved the Libya's old green flag from the plane's doorway.
Maltese authorities were questioning the passengers and doing security checks on them in case another hijacker was among them. Passenger Ibrahim Bashir told Al-Nabaa TV that the passengers were now "trapped" inside buses at the Malta airport and not allowed to leave.
A Libyan culture official said the passengers included 25 artists, writers, and intellectuals from southern Libya who were heading to Tripoli to participate in a cultural forum.
At a news conference later Friday in the Libyan city of Tripoli, Libya's transportation minister defended his country's airport security.
"Security breaches happen everywhere and Libya is not an exception," Minister Milad Matouq said. "Despite the security situation (in the country), things are excellent. This is the first incident since the (2011) revolution."
A plane was heading to Malta to bring the passengers back to Libya after questioning, his ministry said.
But a Libyan lawmaker disputed the minister's comments, saying he was not surprised that a plane from Sabha was hijacked because security measures were "messy" at its Tamanhent airport.
The Sabha airport was closed after tribal clashes two years ago and its air base was turned into a civilian airport for internal Libyan flights only. A small militia from the city of Misrata in northwestern Libya has been guarding it since 2014.
Salah Qalma, a lawmaker from Sabha, said while the airport has an electronic gate at its arrival hall, there are no electronic gates or guards at the adjacent exit gates.
"It's very easy for anyone to enter without passing through the electronic gates," he said.
Qalma also said the airport building has no fence or guards outside it and planes are not separated from the parking lot outside.
Libya, a sprawling oil-rich North African country, has been split between rival parliaments and governments, each backed by a loose array of militias and tribes, Gadhafi was ousted and killed in 2011.
Western nations view the newly-formed U.N.-brokered government as the best hope for uniting the country, but Libya's parliament, which meets in the country's far east, has refused to accept it. Amid chaos, the Islamic State and al-Qaida affiliates have gained a foothold over the past years.
Earlier this month, militias answering to the UN-brokered government seized the Islamic State group's last stronghold in the Libyan city of Sirte.