High-profile personal finance commentator and campaigner Martin Lewis has sold his MoneySavingExpert.com website for up to £87m.

It is being bought by MoneySupermarket.com which runs an online price comparison service.

Martin Lewis will remain as editor-in-chief of MoneySavingExpert, which will retain its editorial independence via an agreed editorial code.

The deal will need to be approved by the Office of Fair Trading (OFT).

Martin Lewis said: "This is great news for MoneySavingExpert.com and its users, ensuring, with or without me, the site will be around for many years to come, maintaining our ethos of 'cutting your costs and fighting your corner'.

"MoneySavingExpert.com has become part of people's daily lives, far bigger than the man who founded it, and now is the right time for it to stand on its own two feet."

Under the terms of the deal, Mr Lewis, who started his website in 2003, will receive an initial £35m plus shares in MoneySupermarket.com worth £25m.

After three years he may receive a further £27m in cash and shares.

Media playback is unsupported on your device Media caption Martin Lewis has sold his money saving website for £87 million

He said he would give some of his proceeds to charity.

"In keeping with the site's aims, when the deal completes, £10 million will go to charity, including £1 million to Citizens Advice, which is facing terrible funding cuts," Mr Lewis said.

The two websites already have a very close business relationship.

In the 12 months to the end of last October, MoneySavingExpert generated revenues of nearly £16m from 39 million users.

Of this income, about 59% was earned from referral fees paid by MoneySupermarket, which is based in Ewloe, Flintshire.

These are generated whenever a reader of MoneySavingExpert clicks on a link that takes him or her through to the MoneySupermarket price comparison service, or when the reader follows a link to a financial product or service provided by MoneySupermarket.

Peter Plumb, chief executive of MoneySupermarket, extolled the virtues of the takeover.

"We've worked closely together for years with the common goal of helping customers save money," he said.

"We'll help MoneySavingExpert.com reach a wider audience and MoneySavingExpert.com will broaden the range of advice and tools we offer, encouraging even more people to take action, tap into the benefits of the internet to find a better deal and make the most of their money."