In a statement on X, formerly Twitter, Mercedes said that Hamilton, who was contracted with the team until the end of 2025, “has activated a release option in the contract announced last year.”
Ferrari, meanwhile, announced that the British driver would be joining the team on a “multi-year contract.”
In a statement on the Mercedes website, Hamilton said: “I have had an amazing 11 years with this team and I’m so proud of what we have achieved together.
“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 39-year-old, who shares the record for the most F1 world titles with Michael Schumacher, joined Mercedes in 2013 after starting his career with McLaren in 2007.
A glittering period followed for the British driver, during which he won six titles over the course of seven years.
Mercedes has struggled to maintain its dominance in recent seasons, but Hamilton, who finished third in last year’s driver standings, signed a contract extension in August, keeping him at the team until the end of the 2025 season.
However, in a shock move first reported by Sky Sports and Spanish media on Thursday, Hamilton will now join one of the Silver Arrows’ great rivals.
“We knew our partnership would come to a natural end at some point, and that day has now come,” said Mercedes team principal Toto Wolff.
“We accept Lewis’s decision to seek a fresh challenge, and our opportunities for the future are exciting to contemplate.”
Mercedes finished second in last season’s constructor standings, three points ahead of Ferrari in third, but both teams were well behind a superior Red Bull team.
Hamilton will join Charles Leclerc at Ferrari in 2025, replacing Carlos Sainz. Writing on X, the Spanish driver confirmed that he will leave the team at the end of 2024 and make an announcement about his future “in due course.”
Speaking to CNN Sport’s Amanda Davies on Thursday, Phil Duncan, a CNN contributor and F1 correspondent with Press Association, said: “Lewis Hamilton’s gone two years without winning [a grand prix], which for him is basically unprecedented, something he’s never had to deal with in his career.
“At the age of 39, he’s probably thinking this is his last big chance, his last big move, and his last chance to drive for Ferrari – a team that’s always appealed to him … This is probably the biggest transfer in Formula One history and it really does breathe new life in the sport.”
(Copyright (c) 2024 CNN. All Rights Reserved. This material may not be published, broadcast, rewritten, or redistributed.)