Supermarket group Morrisons has won a battle to rescue McColl's, the convenience store and newsagent chain, and taken on all 16,000 staff members.
Morrisons beat a rival offer from EG Group, the petrol station empire, owned by the billionaire Issa brothers.
Morrisons will pay off McColl's £170m debts and take on its 1,160 shops and pension schemes, with 2,000 members.
The supermarket's boss said the deal offered stability and continuity for the business, its staff and pensioners.
McColl's was put into administration by PwC on Monday and was immediately sold to Morrisons.
Rob Lewis, joint administrator and partner at PwC, said the deal provided "much needed certainty to McColl's 16,000 staff after a period of understandable concern".
The threat of McColl's going into administration had raised fears that if a buyer was not found there could be UK-wide store closures and job losses.
Morrisons' first offer was knocked back and the Issa brothers looked close to clinching the deal.
The companies battled it out over the weekend. Morrisons matched EG Group's offer to pay off McColl's debts in full and straight away and take on all its stores and staff.
Morrisons' chief executive, David Potts, said: "Although we are disappointed that the business was put into administration, we believe this is a good outcome for McColl's and all its stakeholders.
"This transaction offers stability and continuity for the McColl's business and, in particular, a better outcome for its colleagues and pensioners."
McColl's ran into difficulties as it attempted to update the range of food it sold and came up against Covid-related supply chain problems.
When it emerged last week that the chain was close to collapse a bidding war began.
Morrisons already had a partnership with McColl's as it supplies its convenience stores with stock.
It has also formed a tie-up to convert hundreds of McColl's shops to Morrisons Daily convenience stores. There are already more than 200 operating and these have been performing well.
Meanwhile, the Issa brothers co-own supermarket chain Asda, while their EG Group owns thousands of petrol stations and convenience shops in the UK, Ireland, Europe, Australia and the US.
Both Morrisons and EG Group filed final offers for the business on Sunday.
As McColl's future hung in the balance questions arose around what would happen to its two defined benefit pension schemes. In the end both bidders agreed to support the pension funds and Morrisons was successful.
A spokesperson for McColl's Pension Schemes said: "The trustees will continue to engage with all stakeholders to ensure that members' benefits are protected following the completion of the transaction."
Adam Leyland, editor-in-chief of The Grocer magazine, said Morrisons wanted McColl's for two reasons.
"It was set to lose an estimated £130m if McColl's had gone into administration," he said. "And it would also have put a potentially terminal hole in its wholesale arm, just as it was starting to make a profit."
He said he did not know if Morrisons would keep all of McColl's stores but that it had committed to take them on for now.
"Crucially what this allows is for the Morrisons Daily rollout to continue," he said. "Those stores are less than a quarter of the total McColl's estate but adding five a week it will be a sizeable chain in the not too distant future and those stores are definitely profitable. The challenge will be disposing of the rump of rubbish ones. But Morrisons is in a better position to do that than McColl's was."
The Morrisons takeover was the most reassuring outcome for employees, according to Catherine Shuttleworth founder of Savvy Marketing.
"The Issa brothers will be disappointed not to get it but Morrisons can't let this slip through their fingers," she said.
"Winning the bid gives Morrisons flexibility with the new Morrisons Daily idea and ownership will give them a lot more freedom to move the business forward," she added.
"Like any retail business there's a strong will to keep as many stores as possible but it's a tough time for retailers and ultimately the number of stores will likely have to come under review at some point."
A former senior head of department at McColl's told the some staff felt let down that the rescue had come so late in the day.
"This isn't just a deal, it's people's lives," he said. "McColl's is so important to so many local communities."
Speaking to the under the condition of anonymity he said he was surprised to see Morrisons take over.
"Morrisons have tried in the local arena before and it hasn't been successful so I'm apprehensive to how this will actually work out," he said.
"It's a deal with very low margins, high labour costs and high rent and business rates," he added.
"Morrisons are going to have to work very hard and fast to turn this around."