A Greek court today ordered the state broadcaster back on air while it is restructured, allowing coalition leaders to move towards a compromise that avoids early elections.

The ruling came six days after Prime Minister Antonis Samaras suddenly switched ERT off to save money and please foreign lenders.

The move sparked an outcry from unions and journalists and exposed a rift with his allies.

The top administrative court appeared to vindicate Mr Samaras's stance that a leaner, cheaper public broadcaster must be set up.

However, it also allowed for ERT's immediate reopening as his two coalition partners had demanded, offering all three a way out of an impasse that had raised the spectre of a snap election.

All parties claimed victory from the ruling, which failed to specify whether ERT must restart with programming as before or only partially resume operations until its relaunch.

"The court decision is essentially in line with what we've said: No one has the right to shut down national radio and television and turn screens black," said Fotis Kouvelis, head of the small Democratic Left party in the coalition.

Evangelos Venizelos, head of the Socialist PASOK party, also said the ruling vindicated his party's line and reiterated that he was against going to early elections.

An official from Mr Samaras's New Democracy party - which has already scored a minor victory by securing the latest tranche of bailout funds partly due to ERT's shutdown - said the ruling affirmed the government's position that ERT had been scrapped.

"ERT is shut, ERT is finished," said the official.

A live feed of ERT - whose journalists have continued broadcasting over the internet in defiance of orders - showed workers breaking into applause after the court ruling.

ERT's Symphony Orchestra began a concert outside its headquarters, playing an old news jingle to cheering supporters.

"I've been here seven nights and this is the first time I've seen people smile," said Eleni Hrona, an ERT reporter.

During talks with his allies, Mr Samaras offered to reopen a pared-down version of ERT under temporary management, reshuffle the cabinet and update the coalition's agreement to improve cooperation among parties, a government official said.

Mr Venizelos said Mr Samaras had appeared to accept the option of a cabinet reshuffle and better coordination, and that the three political leaders would meet again on Wednesday to agree on how to implement the court ruling.

"ERT is not the only or the main issue," he said.

"The main issue is that this government must operate as a government of real cooperation and not as a one-party government."

The threat of early elections that had shaken financial markets appeared to recede as talk shifted to the reshuffle.

"No political leader said we must go to elections," another official said. "Elections weren't even discussed."

The coalition parties over the past week had fed fears of a hugely disruptive snap poll by refusing to compromise over an entity widely unloved until its shock overnight closure.

Aware his allies stand to lose heavily in any election, the conservative Mr Samaras had refused to turn the "sinful" ERT back on, vowing to fight to modernise a country he says had become a "Jurassic Park" of inefficiency and corruption.

His coalition partners had previously rejected Mr Samaras's offer of a limited restart of broadcasts.

Opinion polls over the weekend showed a majority of Greeks opposed the shutdown, due rather to its abruptness - screens went black a few hours after the announcement, cutting off newscasters mid-sentence - than to the decision itself.

In Syntagma square outside parliament, thousands gathered to listen to radical left opposition leader Alexis Tsipras protest against the ERT shutdown and attack Samaras as a "great Napoleon of bailouts".

"But he didn't see, nor did he predict, the Waterloo that ERT workers and the great majority of people prepared for him," Mr Tsipras told crowds of flag-waving supporters.