Matt Dunham/Associated Press

LONDON — The British government agreed on Thursday to sell Northern Rock, the lender it nationalized more than three years ago, to Virgin Money, which is controlled by Richard Branson, in a deal that represents a loss for Britain’s taxpayers.

The government is to receive £747 million ($1.18 billion) in cash, and the total proceeds could reach as much as £1.03 billion if certain conditions are met. That compares with the £1.4 billion the government injected into the retail bank in 2010 after it split Northern Rock into two.

It is the first sale of banking assets the British government acquired during the financial crisis to avoid a collapse of the financial sector. The government still owns large stakes in Royal Bank of Scotland and the Lloyds Banking Group, which it is eager to sell at a profit.

“The Northern Rock sale is a very good result for the government because losing the risk is better than going for profit,” Howard Wheeldon, a strategist at BGC Partners, said. “But it was the relatively easy one for the government to get off its back. The real test is going to be R.B.S. and Lloyds.”

Northern Rock ran into trouble when the credit markets seized up in 2008 and was no longer able to finance its operations. Panic spread quickly among its customers, who wanted to get their money back, creating a run on the bank. The government had to step in and Northern Rock was nationalized.

“The sale of Northern Rock to Virgin Money is an important first step in getting the British taxpayer out of the business of owning banks,” said George Osborne, the chancellor of the Exchequer.

As part of the agreement, the government is to receive an additional £50 million ($79 million) in cash in the second quarter of 2012 and about £150 million in capital notes issued by Virgin Money. It also has an option to receive another £50 million to £80 million depending on when and whether the company sells shares in an initial public offering in the next five years.

Virgin Money is buying Northern Rock’s savings bank and mortgage lender, which had a net asset value of £1.1 billion at the end of June, according to U.K. Financial Investments, the organization that managed Northern Rock on behalf of the government.

The government is retaining control of Northern Rock’s asset management business, which is currently operating with a mortgage book worth about £47 billion. When the government nationalized Northern Rock in 2008 it injected £27 billion into the entire bank, according to U.K. Financial.

Wilbur L. Ross Jr., the investor and chief executive of WL Ross & Company, which invests in distressed financial assets, helped finance the Virgin Money takeover. A Middle Eastern sovereign wealth fund contributed less than 10 percent of the financing, Virgin Money said.

Virgin Money pledged to keep all 75 Northern Rock branches and not to lay off any of the 2,100 employees in the next three years, U.K. Financial said. But all the branches will be rebranded as Virgin Money. Its headquarters will remain in Newcastle, in northeast England. The acquisition would add a million customers to Virgin Money’s three million. It would also add £16 billion in deposits and £14 billion in mortgages.

The transaction is subject to approval by the British financial regulator, the Financial Services Authority, and the European Commission.

Deutsche Bank and the law firm of Freshfields Bruckhaus Deringer advised the government on the transaction. Virgin Money was advised by Greenhill & Company.