Treasury officials have held talks into the night with potential buyers of collapsed Dunfermline Building Society.
The Nationwide has been confirmed as the buyer of the Dunfermline Building Society's branches, good loans and deposits.
The UK government hopes a deal will be in place before the society's branches open for business in the morning.
The mutual was put up for sale after incurring losses of £26m.
Ministers say reckless lending has undone the 140-year-old society, which is expected to have lost £26m in 2008.
The Nationwide will also take on Dunfermline's 530 staff, according to the BBC's business editor Robert Peston.
But Dunfermline chairman Jim Faulds has said it is a scandal ministers are not prepared to work for an independent future for the building society.
The Treasury will take over £1bn of commercial property lending and acquired portfolios of mortgages.
He said "faceless" mandarins had refused to talk to the Dunfermline to help secure its future and the Treasury had "sacrificed" the building society.
The deal with the Nationwide has emerged less than 48 hours after the UK Government announced that the building society was to be put on the market.
The plan is for another bank or building society - two of each have been involved in talks - to buy the healthy parts of the Dunfermline and provide reassurance to savers, while the government takes on the riskier loans and investments.
Robert Peston said Britain's largest building society was the natural buyer of the good parts of the Dunfermline and that it has a strong track record of absorbing weaker societies.
Between commercial property and mortgage securities, that exposure could run to £800m.
He said the deal would also preserve the brand name of the society. There are still Cheshire and Derbyshire branches, even though these two societies have recently been bought by Nationwide.
Ministers forced the sale because of financial troubles at what is Scotland's largest building society, sparking the furious response from Mr Faulds on Sunday.
Chancellor Alistair Darling had said the Dunfermline needed between £60m and £100m to keep it going because of its exposure to risky assets.
Swift move
The Treasury ruled out a full government bailout after regulators said the move was not viable.
The move has also taken place quickly, with the aim of securing a buy-out less than 48 hours after the planned sale was announced.
'Good news'
BBC Scotland business editor Douglas Fraser says Mr Faulds expects to be put out of a job on Monday after a wide-ranging attack on the UK government for its handling of the situation.
However, the Dunfermline's outgoing chairman, Jim Faulds, had claimed government funding of £20m-£30m would have helped secure its future and dismissed claims the building society had debts linked to the toxic US sub-prime mortgage market.
Some headquarters staff may also be put out of work later as decision-making shifts away from Dunfermline.
The Scottish Government had offered money to help keep the Dunfermline going, but did not get Treasury approval for the move.
A protest is planned at the building society's head office in Dunfermline on Monday morning by its members, who own the business and feel their views have been ignored.
First Minister Alex Salmond has expressed disappointment that the building society could not continue as a going concern.
The Treasury ruled out a government bailout of up to £100m after regulators said the move was not viable.
The Dunfermline was founded in the Fife town from which it takes its name in 1869, and has 34 branches.
Chancellor Alistair Darling has insisted savers' money will be protected.
A protest at the sale is planned in the town on Monday morning.
The sale of the Dunfermline, which was founded in 1869 and has 34 branches, was forced by the tri-partite regulators - the Bank of England, the Financial Services Authority as well as the UK government.
However, the local MP, Liberal Democrat William Rennie, welcomed the takeover.
"I think it's good news that the jobs have been secured within the Dunfermline Building Society as part of the Nationwide deal," he said.
Are you a Dunfermline customer? Do you work at a DBS branch? Send us your comments using the form below.
"Employees must have been thinking over the weekend about their jobs and future, it's a traumatic experience."
In most cases a selection of your comments will be published, displaying your name and location unless you state otherwise in the box below.
The BBC may edit your comments and not all emails will be published. Your comments may be published on any BBC media worldwide. Terms & Conditions