Octopus Energy has sealed its deal to buy Bulb, a collapsed energy rival that has been funded by billions of pounds in government support for nearly a year.
Octopus said it is taking on Bulb's 1.5 million customers "bringing an end to taxpayer losses and uncertainty for Bulb customers and employees".
It added: "Octopus is paying the government to take on Bulb's customer base - it is believed that this will represent a higher amount per customer than suppliers typically paid to take on any of the 29 suppliers who have failed since September 2021.
"Taxpayers will also benefit from a profit share agreement for a period of up to four years."
The Department for Business, Energy & Industrial Strategy (BEIS) confirmed an agreement had been reached between special administrators of Bulb and Octopus, saying the deal will "protect consumers and taxpayers" and "provides a stable new home for Bulb's customers and 650 employees".
Octopus said it is paying the government "above market value" to take on Bulb's customers.
BEIS said the sale will be completed after a statutory process called an energy transfer scheme, which will move Bulb's relevant assets into a new separate entity that will "protect consumers during the transfer process".
It is expected to take effect by the end of November.
The government will provide financial support to the new entity to purchase energy for Bulb customers over the winter but these costs will later be repaid, Octopus said.
A profit-share agreement will be put in place for the ringfenced business until agreed funding is repaid by Octopus.
This means payments to shareholders or the wider Octopus Energy Group from the ringfenced entity would be restricted until the Government is repaid, Octopus said.
Bulb customers will not experience any disruption to their energy supplies as part of the transfer, BEIS said.
It added there is no change to either firm's customers' supply arrangements, and credit balances are protected.
It comes after Ovo Energy launched an 11th-hour bid to prevent Octopus from swallowing the nationalised supplier.
Ovo submitted an offer for Bulb soon after it collapsed into insolvency a year ago but subsequently pulled out of the auction.
Taxpayers' rescue of Bulb is set to cost the government up to £4bn.
Bulb's collapse in November 2021 was the most significant among dozens of supplier failures, with Ofgem, the industry regulator, facing heavy criticism for its approach to licensing new entrants to the market.
The government has already been forced to spend billions of pounds buying gas to supply Bulb customers because the company did not hedge its purchases in order to fix its cost base.
Wholesale gas prices have soared over the last year, with Vladimir Putin's invasion of Ukraine having a particularly pronounced impact on global energy markets.
That would allow the buyer to secure sufficient forward supplies of gas to steer the company through the winter months.
Octopus intends to repay the government funding over a period lasting a number of months, according to sources close to the situation.