Two hijackers who diverted a Libyan passenger plane to Malta claiming to have a grenade have surrendered peacefully following hours of tense negotiations.

There were 117 people, including six crew members, on board the hijacked Afriqiyah Airways Airbus A320, which was on an internal flight from Sabha in south east Libya to the capital city of Tripoli.

The hijackers, who declared loyalty to Libya’s late leader Muammar Gaddafi, were carrying two pistols and a hand grenade, according to the Maltese Prime Minister Joseph Muscat. He later said that initial forensic examination showed the weapons were replicas.

Mr Muscat effectively broke the news on Friday, tweeting: “Informed of potential hijack situation of a Libya internal flight diverted to Malta. Security and emergency operations standing by.”

All flights to Malta International Airport were immediately cancelled or diverted and emergency teams, including security officers and negotiators, were sent to the airport tarmac.

The passengers – 82 men, 28 women and one child – were allowed to leave the plane before the hijackers walked out themselves with the last of the crew.

Mr Muscat told reporters the hijackers wanted negotiators to go on board but his government refused and insisted that all passengers and crew be released.

“Hijackers surrendered, searched and taken in custody,” wrote Mr Muscat at 3:44pm local time, two hours after the plane’s doors opened and a staircase was moved over to let freed passengers begin disembarking in groups.

After passengers had left the plane, a man briefly appeared at the top of the steps with a plain green flag resembling that of Gaddafi’s now-defunct state.

The flag was adopted in 1977 by Libya when Gaddafi became the country’s leader through a coup d’etat, until his death in 2011.

People disembark from a hijacked Libyan Afriqiyah Airways Airbus A320 on the runway at Malta Airport (Reuters)

Libya’s Channel TV station said one hijacker, who gave his name as Moussa Shaha, had said by phone he was the head of Al-Fateh Al-Jadid, or The New Al-Fateh.

Al-Fateh is the name that Gaddafi gave to September, the month he staged a coup in 1969, and the word came to signify his coming to power.

In a tweet, the TV station later quoted the hijacker as saying: “We took this measure to declare and promote our new party.”

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, since Gaddafi’s death.

Western nations view the newly-formed UN-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, Isis and al-Qaeda affiliates have gained a foothold over the past year.

Earlier this month, militias answering to the UN-brokered government seized an Isis stronghold in the Libyan city of Sirte.

In pictures: Isis' Libyan stronghold of Sirte Show all 10 1 /10 In pictures: Isis' Libyan stronghold of Sirte In pictures: Isis' Libyan stronghold of Sirte Isis in Sirte Isis fighters parade through in Sirte in 2015 In pictures: Isis' Libyan stronghold of Sirte Isis in Sirte Islamic State (IS) group jihadists on the outskirts of Libya's western city of Sirte AFP/Getty In pictures: Isis' Libyan stronghold of Sirte Isis in Sirte A photo of a billboard in Sirte, Libya, listing seven rules for women's clothing, saying they must be loose-fitting and undecorated HRW/social media In pictures: Isis' Libyan stronghold of Sirte Isis in Sirte Isis militants process down a street in the coastal city of Sirte in Libya this week; the group has heralded Libya as its ‘strategic gateway’ to attack Europe AFP/Getty Images In pictures: Isis' Libyan stronghold of Sirte Isis in Sirte An Isis lecture on Sharia at the Ouagadougou complex in Sirte, Libya, in 2016. HRW/social media In pictures: Isis' Libyan stronghold of Sirte Isis in Sirte A sign reading "The city of Sirte, under the shadow of Sharia" as smoke rises in the background while forces aligned with Libya's new unity government advance on the eastern and southern outskirts of the Islamic State stronghold of Sirte on 9 June. Reuters In pictures: Isis' Libyan stronghold of Sirte Isis in Sirte Fighters loyal to Libya's GNA prepare to launch attacks against Isis as they continue their resistance on the outskirts of the western city of Sirte Getty In pictures: Isis' Libyan stronghold of Sirte Isis in Sirte Forces loyal to Libya's UN-backed unity government are seen during clashes with jihadists of the Islamic State (IS) on the western outskirts of Sirte on June 2, 2016. AFP/Getty Images In pictures: Isis' Libyan stronghold of Sirte Isis in Sirte Forces loyal to Libya's UN-backed unity government fire during clashes with Isis around 14 miles west of Sirte on June 2, 2016. AFP/Getty Images In pictures: Isis' Libyan stronghold of Sirte Isis in Libya

Airport security in Libya can be poor and is not always under state control, according to BBC journalist Rana Jawad.

“Every airport in Libya is poorly secured and technically run by one armed group or another, outside state control,” she wrote on Twitter.