The deal brings the total cash pumped into Germany's three biggest Russian gas importers - Uniper, former Gazprom unit Sefe and EnBW's VNG division - to at least 40 billion euros.
Nationalising Germany's largest importer of Russian gas is the second move in a week by the government to take control of an energy business and is part of a wider European response to the winter crisis, including France taking over EDF.
Germany last week also took control of a Russian-owned oil refinery, which supplies 90% of the capital's fuel, putting a Rosneft unit under the trusteeship of the industry regulator and taking over the Schwedt plant.
Uniper, whose shares closed 25.3% lower, burned through its cash buying alternative supplies after Moscow cut gas flows to Germany, triggering an initial 15 billion euro state rescue package in July.
But as with other European energy companies hit by soaring gas prices, it became clear the bailout was not enough to cover Uniper's deepening losses. Germany will now inject yet more cash, partly by buying out Finnish utility Fortum's 56% holding for 500 million euros, or 1.70 euros per share.
Fortum shares ended the day up 9.5% on the news, with analysts at Bernstein saying the deal "allays investor fears and provides a clean break" for the Finnish group.
After completing a capital increase and the Fortum share buy, which excludes the Finnish firm's subscription rights, Germany will hold 99% of Uniper, its economy ministry said.
"The state will - that's what we're showing now - do everything possible to always keep the companies stable on the market," German economy minister Robert Habeck told reporters.
Berlin has said it would review an application earlier this month by VNG which asked the government for aid to stay afloat.
Habeck also said Berlin will impose a gas levy on consumers as planned from the start of October to help importers with the additional costs of replacing Russian gas.
However, there will be an analysis of whether it is in accordance with German law after the nationalisation of Uniper, which could take about three months, he said.
German Finance Minister Christian Lindner meanwhile said that the levy was finalised and there would be no further assessment, apparently contradicting Habeck.
German gas importers face losses because they cannot directly pass the higher gas prices on to their customers. Uniper will continue to pursue legal action against Gazprom, its former main supplier, to claim back damages, Chief Executive Klaus-Dieter Maubach told reporters.
'WE CANNOT BE HAPPY'
While German consumers have been largely protected from the price hikes so far, other Europeans are paying very high prices for their energy. Fortum has taken on sizeable Uniper losses, which has caused discontent in Finland.
Fortum said that under the deal it will be paid back a 4 billion euro parent company loan and released from a 4 billion euro parent guarantee it had given Uniper earlier this year.
"We are investing in Uniper with 8 billion in equity and are effectively buying Fortum out," Habeck said, while Finland's government, which has a 50.76% holding in the Finnish utility, said it would have to live with the deal.
Fortum said in March 2020 it had made investments worth 6.5 billion euros to give it a 69.6% stake in Uniper. It later raised its stake to 80%, which it held until the July dilution.
"We have invested around 7 billion (euros) into the equity and we got about 900 million in dividends throughout the years of ownership and now we would recover through this agreement half a billion for the shares," Fortum CEO Markus Rauramo said.
"It is clear that we cannot be happy about what has happened," he added on a call with investors.
For years, Fortum has been a significant contributor to the Finnish state budget through dividends, but in the second quarter of this year alone, it reported a loss of 9.1 billion euros due to Uniper's losses in gas trading.
Under Wednesday's agreement, Fortum will not take on Uniper's losses for the third quarter, as it would have under the July deal. This will free up 5 billion euros to Fortum, Rauramo said.
($1 = 1.0090 euros)