The Dunfermline was put up for sale after incurring losses of £26m.
The Nationwide is also expected to take on Dunfermline's 530 staff, according to the BBC's business editor Robert Peston.
The BBC goes on to say that:
The Treasury will take over £1bn of commercial property lending and acquired portfolios of mortgages.
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 sale was forced by the Bank of England, the Financial Services Authority (FSA) and the UK Government.
The Treasury ruled out a government bailout of up to £100m after regulators said the move was not viable, however the Chancellor has issued an assurance that members' money would be safe.
The Dunfermline was founded in the Fife town from which it takes its name in 1869 and has 34 branches.
Update at 08:30 - Nationwide has now been confirmed as the purchaser of the Dunfermline.