Mid-sized UK bank CYBG has agreed to buy Virgin Money in a £1.7 billion all-share deal that it said will create Britain's sixth-largest bank by assets and a stronger challenger to the country's top four lenders. 

Britain's biggest bank merger since the financial crisis was clinched by this month's sweetened bid from CYBG.

It will give Virgin Money shareholders, which include entrepreneur Richard Branson, about 38%of the combined group.

The merged company will be about twice the size of its largest rival among Britain's smaller banks and be able to draw on the firepower of the Virgin brand, for which it will pay a royalty. 

CYBG chief executive David Duffy will lead the enlarged lender.

Virgin Money's CEO Jayne-Anne Ghadia will act as a senior adviser for an unspecified period, as it throws down the gauntlet to the sector's big guns. 

Virgin Money CEO Jayne-Anne Ghadia will act as a senior adviser after the deal

"The combination of CYBG and Virgin Money will create the first true national competitor to the status quo in UK banking, offering a genuine alternative for consumers and small businesses," Duffy said in a statement. 

Shareholders of both banks still need to approve the takeover, but John Cronin, analyst at stockbroker Goodbody, said both sides are likely to agree to the terms. 

"Ultimately, we believe this is a great deal for both sets of shareholders and we expect it should receive their support," he said. 

Virgin Money investors will receive 1.2125 CYBG shares per Virgin Money share. Branson owns 35% of Virgin Money.

The agreement comes after over a month of talks between the two lenders and beats today's deadline for CYBG, owner of Clydesdale and Yorkshire Bank, to make a firm offer or walk away under British takeover rules. 

The banks said they expect to benefit from £120m in annual pretax cost savings, helped by the loss of about 1,500 jobs, which would leave the group with a headcount of around 8,000. 

CYBG CEO David Duffy - a former AIB chief

While banding together will help the duo to fight competitive pressures from established players and tech-savvy newcomers, they face a tough task if they are to take on the so-called Big Four of Lloyds, Royal Bank of Scotland, HSBC and Barclays. 

The new lender would be the main bank for only 2% of retail banking customers, compared with about 24% for market leader Lloyds, according to data from industry body RFi Group. 

CYBG Finance Director Ian Smith said the new bank will be "better rather than bigger", leveraging technology to improve services for its enlarged customer base. 

"Really the battleground for us is customer experience," he said. 

Virgin Group CEO Josh Bayliss said CYBG is the partner Virgin Money needs to continue to grow. 

"We look forward to helping the combined business rebrand to Virgin Money," he said. 

CYBG will pay a fixed royalty to keep the Virgin Money brand, starting at £12m in the first year and rising to £15m in the fourth year. 

Like Duffy - a former chief executive at AIB - CYBG Chairman Jim Pettigrew and finance chief Smith will retain their roles in the combined group.