Energy supplier Octopus Energy is to buy its smaller competitor Bulb.
Bulb collapsed last year amid rising gas and electricity prices and has since been run by the UK Government.
Its 1.5million customers will not see any change or disruption to energy supplies, the Department for Business, Energy and Industrial Strategy said.
The value of the transaction has not been published, but the BBC understands Octopus - which will now have nearly five million customers - paid the government between £100million and £200million.
The deal is expected to be completed by the end of November.
Business Secretary Grant Shapps said this would bring "vital reassurance and energy security to consumers across the country at a time when they need it most".
For Bulb customers, credit balances on bills will be protected and direct debits automatically transferred.
Big cost to taxpayers
The Financial Times says the acquisition will see Bulb move out of effective nationalisation that has cost taxpayers in excess of £4billion, after it became the largest and most high-profile of the UK energy retailers to collapse last year.
Bulb was Britain's seventh-largest household energy supplier when it went under last November as the result of soaring energy prices and its failure to buy gas in advance, but was deemed too large at the time to be absorbed by other suppliers.
Its bailout is expected to be the most expensive since the rescue of RBS during the 2008 financial crisis.
Octopus was the front runner to take over Bulb's customers since the summer, but had to see off an 11tth-hour bid from rival Ovo Energy that emerged this month.
Greg Jackson, the boss of Octopus, said the company was determined to provide a "stable home for the future" for Bulb's customers and staff. London-based Bulb has 650 employees.
Mr Jackson told the BBC he was confident the takeover would be smooth, saying the firm had "a great track record" when it came to moving customers across companies.
Share of profits
Octopus has agreed to share profits - if any are made from its new Bulb customers - with the government, for up to four years.
Mr Shapps said the deal highlighted the government's "overriding priority" to protect customers.
He added he would do everything he could to "ensure our energy system provides secure and affordable energy for all".
Octopus will continue to use Bulb's technology and branding "for a transitionary period", the government's statement said.
Before the Bulb acquisition, Octopus had 3.4million customers.