Lewis Hamilton will leave Mercedes at the end of the 2024 season and join Formula One rivals Ferrari on a multi-year deal in 2025.
The 39-year-old only signed a new two-year deal with Mercedes last summer.
However, it is understood his contract contained a break clause after one year, which the Briton has chosen to activate.
Hamilton said he was “so proud” of the success he had achieved in 11 years with Mercedes.
The seven-time world champion added: “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.”
Hamilton’s switch to the Italian team is one of the biggest driver transfers Formula 1 has ever seen – if not the biggest.
He is set to partner Charles Leclerc in 2025, leaving Spaniard Carlos Sainz facing his last year as a Ferrari driver.
Hamilton joined Mercedes from McLaren for the 2013 season and secured six of his seven championships with the team.
He also won 82 of his record 103 races with the Silver Arrows.
Team principal Toto Wolff said the pairing of Mercedes and Hamilton “has become the most successful the sport has seen”.
“And that’s something we can look back on with pride,” he added.
Hamilton said: “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.
“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.”
Sainz confirmed via X, formerly Twitter, he will depart Ferrari at the end of this season.
“We still have a long season ahead of us, and, like always, I will give my absolute best for the team and for the Tifosi all around the world,” wrote Sainz.
The 29-year-old said news about his future would be announced “in due course”.
Hamilton’s dominant run with Mercedes has stalled in recent seasons, with the team unable to provide him with a car to challenge the power of Max Verstappen and Red Bull.
His last race win was at the Saudi Arabian Grand Prix in 2021 and a year later he finished sixth in the championship – two places lower than new team-mate George Russell.
Hamilton ended the 2023 campaign third in the standings, but he was 341 points behind first-placed Verstappen, who claimed his third consecutive drivers’ title.
Hamilton’s Ferrari move ‘incredibly dynamic’ – Mansell
The whispers Hamilton was about to join Ferrari left many supporters wondering if silly season had started early this year, but the rumour mill on this occasion was 100% true.
Nigel Mansell, who spent two seasons with the Scuderia from 1989 to 1990, thinks the huge move will be a positive one for the sport.
“I think it’s fantastic for the fans and it’s incredibly dynamic,” Mansell told BBC Sport.
“I think for Lewis, he’ll probably go on and finish his career with Ferrari, it’s like a dream come true for him, I would imagine, because going to Ferrari is everything.”
Hamilton celebrated his 39th birthday last month and by the time the 2025 season gets under way, he will be the latest F1 driver to still be racing at the age of 40.
Mansell secured the 1992 drivers’ championship during his second stint with Williams and said age will play no part in Hamilton’s ability to be competitive.
“People are saying Lewis is now too old,” he said. “At 39? No. I won my championship at 39 and I could have gone on, but the politics got involved.
“But Lewis, if he’s motivated, he’s got several, if not a lot more years left, I think it’s just fantastic.
“Yes, Lewis can do it, but I’m sure Max [Verstappen] will do everything he can to stop him. And I’m sure Ferrari this next year will do everything they can to stop him.
“But I think we’ve got a great Formula 1 season coming up, and it certainly looks like we’re going to have an exciting one in 2025.”