Libya's Supreme Court has ruled that the June election that produced the internationally recognized legislature and government was unconstitutional.

The ruling on Thursday will almost certainly plunge the country deeper into crisis. The parliament elected in June has appointed a government that has been fighting Islamic militant groups and seeking to restore law and order in the vast, energy-rich North African nation.

The elected parliament sits in the city of Tobruk in the far east. Islamist-allied militias control the capital Tripoli, where a rival Islamist-dominated parliament remains in place despite an expired mandate.

Libya has been gripped by unrest since the 2011 uprising that toppled dictator Moammar Gadhafi, as the weak central authorities have struggled to reign in regional, ideological and other militias who control much of the country.