The German government will become the majority shareholder of struggling energy giant Uniper, the previous majority owner, Finland's Fortum, said.

A deal between Fortum, the German government and Uniper would allow Berlin to gain full control of Uniper to secure Germany's energy supply, the statement said. Under the plan, which is still awaiting approval from the European Commission, Germany would own 98.5 percent of the company. Economy Minister Robert Habeck said at a news conference that Fortum would receive 480 million euros for its shares and indirectly participate in the bailout through a loss of capital, Politico reported.

The German government also agreed to a further €8 billion capital increase with state bank KfW for the interim financing needed for Uniper through a €13 billion loan.

However, the move creates legal problems for the government, which is about to impose an emergency gas tax to finance a fund to support struggling energy companies. The Finance Ministry is checking whether the tax is constitutionally appropriate for a state-owned company, Robert Habeck said.

Uniper, the country's largest natural gas supplier, has faced liquidity shortages and financial losses after Russia's Gazprom stopped supplying gas under long-term contractual contracts, forcing Uniper to buy replacement gas on spot markets at rates up to six times higher than last year.

Germany recently acquired a local subsidiary of Rosneft and is reportedly in talks with two other gas importers.