The shock news on Thursday sees seven-time F1 world champion Hamilton leave Mercedes after 11 years in which he won six world titles.
Hamilton, 39, has exercised a release clause in his two-year contract to leave the Silver Arrows and take up a “multi-year contract” with the Scuderia.
It leaves Sainz, who claimed Ferrari’s only victory last year in Singapore, somewhat in the lurch and without a drive for 2025.
The Spaniard said in a brief statement on Twitter/X: “Following today’s news, Scuderia Ferrari and myself will part ways at the end of 2024.
“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.
“News about my future will be announced in due course.”
Ferrari’s short statement on Thursday, confirming the signing of Hamilton, was notable for no reference to Sainz’s future.
Negotiations between Ferrari and Sainz started almost a month ago, with the 29-year-old’s current deal expiring at the end of the 2024 season.
Sainz is a two-time race winner, having claimed his first F1 victory in his 150th race at Silverstone in July 2022.
The Spaniard joined Ferrari in 2021 from McLaren. He started his career at Toro Rosso in 2015 and has also driven for Renault.