World champion Lewis Hamilton will race for Mercedes in Formula 1 for at least a further two seasons.

The 33-year-old Briton has signed a new contract with the German manufacturer that lasts until the end of 2020.

BBC Sport understands Hamilton will earn at least £30m a year, rising to a maximum of £40m, depending on bonuses.

Hamilton said a new contract had been "a formality" since he sat down with Mercedes F1 boss Toto Wolff to begin discussions last winter.

He said: "It's good to put pen to paper, announce it and then get on with business as usual.

quote There is not much about Lewis that hasn't been said already - he is one of the all-time greats and his track record speaks for itself Toto Wolff Mercedes F1 boss

"I have been part of the Mercedes racing family for 20 years and I have never been happier inside a team than I am right now.

"We are on the same wavelength both on and off track - and I am looking forward to winning more in the future and shining even more light on the three-pointed star. I'm very confident that Mercedes is the right place to be over the coming years."

Mercedes have dominated F1 since the introduction of turbo hybrid engines in 2014, winning four consecutive drivers' and constructors' championship doubles.

Hamilton has won three of those titles, with the fourth going to former team-mate Nico Rosberg, who retired after becoming champion in 2016.

Hamilton's first world title came with McLaren, using Mercedes engines, in 2008.

He is eight points behind Ferrari's Sebastian Vettel in this year's championship before this weekend's German Grand Prix, which marks the halfway point of the season.

Hamilton added: external-link "Although we have enjoyed so much success together since 2013, Mercedes is hungrier than ever.

"The competitive passion that burns bright inside me is shared by every single member of this group - always chasing the next improvement and digging even deeper to make sure we come out on top.

"I can't wait to see what we can achieve together in the next two and a half seasons."

Wolff said: "There has understandably been a lot of interest and speculation around the whole process, so it's good to put all of that to rest and get this thing announced.

"We signed the final documents this week and didn't want to keep people waiting any longer!

"There is not much about Lewis as a Formula 1 driver that hasn't been said already - he is one of the all-time greats and his track record speaks for itself.

"But what I enjoy most about working with him is getting to know the man inside the racing helmet: his relentless drive for self-improvement, his emotional intelligence as a team member and his loyalty to those around him.

"Mercedes has become Lewis' home in Formula 1. I am very confident that we have some incredible chapters of our story together still to come."

Mercedes still have to confirm the identity of Hamilton's team-mate after this season, but Finn Valtteri Bottas is expected to be confirmed in the coming weeks.

'No reason to look elsewhere' - analysis

Lewis Hamilton and Mercedes have been saying for months that a new contract was only a matter of time - and this announcement proves they were true to their word.

The delay on a deal that they had initially expected to conclude over last winter led to speculation that Hamilton might be looking around.

In fact, the length of time it has taken can be explained simply by Hamilton's busy schedule and the pressures of an F1 season - especially one in which Mercedes face their toughest fight since the start of the turbo hybrid era.

There was no reason for Hamilton to look elsewhere. The only other team that could afford him and offer him a similar chance of success would be Ferrari, but they are committed to Sebastian Vettel until 2020, and F1's top teams tend not to like having two A-listers in the cockpit at the same time. And Hamilton has repeatedly said he sees no reason to leave, and has not had discussions elsewhere.

Why only two years? Simply because that is as long as Mercedes are currently committed to F1.

Like all teams bar Renault, Mercedes have a contract only until 2020, and the sport's bosses are currently in the process of what are proving to be long, complex and not a little fractious negotiations over the shape of F1 from 2021 onwards.

Assuming Mercedes continue after 2020, will Hamilton stay with them? It's most likely. Any uncertainty would focus mainly on whether Hamilton is motivated to continue racing at that point, when he will be approaching 36.

Gallery - Hamilton at Mercedes

Lewis Hamilton and Nico Rosberg at the launch of the Mercedes car in February 2013

Hamilton came fifth in his first race for Mercedes - the Australian Grand Prix - in March 2013

Hamilton's first win at Mercedes came in his 10th race, the Hungarian Grand Prix. It would be Hamilton's only win in 2013 as he finished fourth in the drivers' championship

Hamilton would dominate in 2014 and this was his first win of the season in Malaysia. He would win 11 of the 19 races and finish on the podium a further five times

Hamilton, pictured with father Anthony and then-girlfriend Nicole Scherzinger, celebrates his second world title, and first with Mercedes, at the Abu Dhabi Grand Prix in November 2014

Another world title came Lewis Hamilton's way in 2015 with 11 victories in 19 races

Hamilton missed out on the world title in 2016, losing out to team-mate Rosberg. The German retired from Formula 1 soon after his title win, with Valtteri Bottas his replacement