Libya's supreme court ruled on Monday that the election of prime minister Ahmed Miitig in a chaotic session in the interim parliament in early May was unconstitutional.
"The court has judged the election of Miitig at the General National Congress (the interim parliament) as unconstitutional," a judge at the court said after a short hearing.
Outgoing premier Abdullah al-Thani had said he would await the judiciary's ruling before deciding whether to hand over power.
The ruling will be examined by the administrative court on Monday, lawyers said.
Thani had 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.
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 GNC.
The GNC was elected in July 2012, in Libya's first ever free polls, almost one year after the revolution which ousted the regime of longtime dictator Moamer Kadhafi.
Its legitimacy was challenged after the GNC prolonged its mandate, due to expire last February, until December 2014.