Over the past two weeks, Greek energy companies have been in a frantic scramble for cash to avert an energy crunch caused by the country's economic crisis and flawed regulation.

The 40 million euros had belonged to two small electricity retailers that went out of business earlier this year and were frozen as part of a judicial investigation into their bankruptcy.

Greece's power regulator RAE had repeatedly urged authorities to unblock these funds to settle the two companies' debt to power grid operator LAGHE, which runs a deficit of more than 350 million euros.

Greek court officials, who had hitherto refused to unblock the funds, relented after LAGHE's deficit caused a financial chain reaction that left power producers and state-run natural gas company DEPA short of cash to pay suppliers.

"There is a risk of electricity disruptions in the coming days... part of the money will be used to pay electricity producers," a court official who declined to be named told Reuters.

The stock of PPC, Greece's biggest power producer, rose 3 percent after the news, outperforming a 0.4 percent drop in the Athens stock exchange index.

Both PPC and DEPA are already in talks with banks for emergency loans that would allow them to maintain operations. DEPA is looking for cash to pay its suppliers, such as Russia's Gazprom, a total 120 million euros for contracts due this month.

A DEPA official who declined to be named said that the company managed on Monday to pay its obligations to Italy's ENI.

($1 = 0.7993 euros)

(Reporting by Harry Papachristou; Editing by Elaine Hardcastle)

Stocks treated in this article : Public Power Corp., Eni S.p.A., Gazprom OAO