The hijacked Airbus A320 flight, operated by Afriqiyah Airways, was traveling from the Libyan oasis city of Sabha to Tripoli when it was diverted to Malta

Receive the latest national-international updates in your inbox

An Afriqiyah Airways plane from Libya stands on the tarmac at Malta's Luqa International airport, Friday, Dec. 23, 2016. Malta's state television says two hijackers who diverted a Libyan commercial plane to the Mediterranean island nation have threatened to blow it up.

After hours of tense negotiations, two Libyans who hijacked a plane from Libya to Malta and threatened to blow it up surrendered peacefully Friday, allowing 118 passengers and crew to leave the plane before walking out themselves with the last of the crew.

The hijacked Airbus A320 flight, operated by Afriqiyah Airways, was traveling from the Libyan oasis city of Sabha to Tripoli when it was diverted to Malta midmorning on Friday.

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.

Malta's prime minister, Joseph Muscat, announced that the hijacking of the Libyan plane was over in a tweet at 3:44 p.m. local time.

They have "surrendered," been "searched and taken in custody," he tweeted.

The hijackers, after negotiations, allowed the plane's doors to open at 1:44 p.m. and a staircase was moved over to let freed passengers begin disembarking in groups.

In a series of tweets, Muscat said 65 people were allowed to leave, then another 44, including some crew, then the hijackers and the final crew members. All were seen leaving the aircraft without hand luggage.

The company said on its Facebook page that 118 people, including 7 crew members, were on board the hijacked plane.

Ali Milad, the pilot, told Libya Channel TV network that initially the hijackers had asked him to head to Rome. He identified the two hijackers as Moussa Shaha and Ahmed Ali, Libyans who other 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 Fateh revolution after his coup in 1969.

After many of the hostages left the plane Friday afternoon, someone, apparently a hijacker, waved the old green Libyan flag from the plane's doorway.

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.