FRANKFURT/HELSINKI (Reuters) -Uniper on Friday received 15 billion euros ($15.2 billion) in guarantees and equity as the German government stepped in to save the gas importer that is the biggest casualty of Europe’s energy crisis so far.

The state bail-out caps weeks of intense negotiations between Germany and Finland, which controls Uniper’s majority shareholder Fortum. It provides a lifeline after falling Russian gas supplies drained the company’s finances.

Uniper shares initially rose 5% after the announcement, but by 1035 GMT were down 14%.

As part of the deal, the German government will take a 30% stake in Uniper. Fortum will end up holding 56% in Uniper, down from around 80% currently.

“We are living through an unprecedented energy crisis that requires robust measures,” Fortum CEO Markus Rauramo said, adding the deal reflected the interests of all parties. “We were driven by urgency and the need to protect Europe’s security of supply in a time of war.”

Following the immediate rescue, Uniper, Fortum and the German government will work on a long-term solution to reform the company’s wholesale gas contract architecture, which has exposed the group to billions in losses.

The parties intend to agree on the longer-term solution by the end of 2023, they said.

A drop in Russian gas supplies meant that, rather than being able to rely on long-term price agreements, Uniper had to buy expensive gas on the spot market to make up for the shortfall.

Friday’s agreement will allow Uniper to pass on higher gas prices, which have risen eight-fold as a result of Moscow cutting supplies, to customers, but German Chancellor Olaf Scholz said the government was looking at relief measures.

($1 = 0.9847 euros)

(Reporting by Christoph Steitz, Essi Lehto, Matthias Inverard, Holger Hansen, Andreas Rinke, Markus Wacket; Editing by Maria Sheahan, Kirsti Knolle and Barbara Lewis)