TRIPOLI : Libya’s supreme court on Monday ruled as unconstitutional the election of premier Ahmed Miitig in a chaotic parliamentary session, raising hopes for a possible solution to the country’s smouldering political crisis.

Outgoing prime minister Abdullah al-Thani had refused to recognise Miitig’s government, saying he would await the judiciary’s decision before handing over power.

But Miitig convened his first cabinet meeting last week despite Thani’s objections, and the two rival premiers disputed power in Tripoli, laying claim to the largely lawless North African nation’s huge reserves from oil and gas.

“The court has judged the election of Miitig at the General National Congress (the interim parliament) as unconstitutional,” a judge at the court said on Monday after a short hearing.

The ruling would be examined by the administrative court later Monday, lawyers said.

Thani announced his resignation earlier this year after an armed attack on his family, but he insisted that his successor should be chosen by a new parliament rather than its contested predecessor and refused to recognise Miitig’s cabinet.

After refusing to hand over power, Thani convened his cabinet last week as Miitig’s government held its first session, reportedly in a luxury hotel since his predecessor was at the time occupying the seat of government.

The political standoff between the rival cabinets amid rising unrest across the country allowed rogue general Khalifa Haftar to press an offensive against Islamists in the restive eastern city of Benghazi.

Haftar launched the attack, dubbed “Operation Dignity”, last month with troops from his so-called National Army. He has rallied support among the public and members of the security forces have joined his forces.

Near daily attacks in the eastern city of Benghazi, cradle of the 2011 revolt against dictator Moamer Kadhafi, have killed dozens of members of the security forces. No group has claimed the attack, but they have been blamed on radical militias based in the city.

A source in Miitig’s office said his cabinet had discussed security issues in their first meeting.

Miitig, 42, an independent backed by the Islamists, had been due to lead the country for a short interim period until June 25, when the country is due to hold an election to replace the congress.

He did not immediately comment. If he accepts the court’s decision, Thani is expected to remain in office until the June 25 vote is held.

Miitig’s election took place at a second session of the GNC in early May, days after gunmen stormed the building to interrupt an earlier ballot.

Several liberal lawmakers accused Islamist blocs within the interim parliament of allowing late arrivals at the session to cast their votes after the initial result was announced to make up the 121 votes needed, after Miitig had garnered only 113 votes.

The GNC’s vice-president, liberal MP Ezzedine al-Awami, had called Miitig’s installation as prime minister a “coup d’etat.”

Miitig would have been Libya’s fifth premier since the revolution that ousted longtime dictator Moamer Kadhafi in 2011.

Successive governments in Tripoli have failed to stamp their authority on militias of rebels who fought Kadhafi and have refused to surrender their arms or join the regular security forces.

The GNC was elected in July 2012, in Libya’s first ever free polls, almost one year Kadhafi’s ouster.

Its legitimacy was challenged after the GNC prolonged its mandate, due to expire last February, until December 2014.