Seven-time Formula One world champion Lewis Hamilton will make a surprise switch to Ferrari next year, and leave his current team, Mercedes, after the 2024 season.

"Lewis has activated a release option in the contract announced last August and this season will therefore be his last driving for the Silver Arrows," Mercedes said in a statement.

Hamilton had signed a two-year contract with Mercedes for the 2024 and 2025 seasons, but that deal contained a clause allowing him to leave after one season.

"I have had an amazing 11 years with this team and I'm so proud of what we have achieved together," Hamilton said. "Mercedes has been part of my life since I was 13 years old. It's a place where I have grown up, so making the decision to leave was one of the hardest decisions I have ever had to make.

"But the time is right for me to take this step and I'm excited to be taking on a new challenge."

The Italian team subsequently confirmed the arrival of the 39-year-old Briton, who is due to partner with current Ferrari driver Charles Leclerc.

"Ferrari is pleased to announce that Lewis Hamilton will be joining the team in 2025, on a multi-year contract," the team said in a statement.

Hamilton previously held discussions with Ferrari in 2019 about joining the team in the future.

The BBC reported that Mercedes staffers were called to a meeting with boss Toto Wolff at their UK headquarters on Thursday to be told Hamilton will leave at the end of the 2024 season and head to one of Formula One's most storied names.

Several reports say Hamilton's agreement with Ferrari was put together hastily as the team was in talks about a contract extension with Spanish driver Carlos Sainz, whose deal runs out at the end of this season.

Hamilton won the last of his world titles in 2020 but lost the 2021 championship in controversial fashion to Max Verstappen when the race director ignored the safety car rules in Abu Dhabi, effectively blocking the Briton's route to victory in both that grand prix and the championship.

The Dutch Red Bull driver, who is 13 years younger than Hamilton, has dominated the F1 scene ever since.

Hamilton finished sixth in the drivers' standings in 2022 and third in 2023.

"Lewis will always be an important part of Mercedes motorsport history," Wolff said.

"However, we knew our partnership would come to a natural end at some point, and that day has now come. We accept Lewis's decision to seek a fresh challenge."

Hamilton has never hidden his anger at the 2021 incident in Abu Dhabi, believing he was robbed of an eighth title that would have broken a tie with Ferrari legend Michael Schumacher for the most ever.

He has also made clear his frustration with the performance of his Mercedes car in the last two years and believes a move to Ferrari will enable him to reignite his challenge for that elusive eighth title.

Ferrari, however, has also suffered patchy form in the last few seasons, although it seemed to find momentum towards the end of 2023.

That improvement was not enough to prevent Mercedes from beating Ferrari to second place behind Red Bull in the constructors' championship.

"I will be forever grateful for the incredible support of my Mercedes family, especially Toto for his friendship and leadership and I want to finish on a high together," said Hamilton.

"I am 100% committed to delivering the best performance I can this season and making my last year with the Silver Arrows, one to remember."