Hamilton’s switch to the Italian team is one of – if not the biggest – driver transfers Formula 1 has ever seen.
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 will be announced “in due course.”