Sainz arrives at the team as a replacement for Sebastian Vettel, who confirmed on Tuesday that he would not be returning to Ferrari after the 2020 season.
The 25-year-old becomes the sixth Formula 1 driver to race for Ferrari since 2010 and the third ever Spaniard to compete for the Maranello-based squad.
Ferrari team principal Mattia Binotto said: “I’m pleased to announce that Carlos will join Scuderia Ferrari as from the 2021 championship.
“With five seasons already behind him, Carlos has proved to be very talented and has shown that he has the technical ability and the right attributes to make him an ideal fit with our family.
“We’ve embarked on a new cycle with the aim of getting back to the top in Formula 1.
“It will be a long journey, not without its difficulties, especially given the current financial and regulatory situation, which is undergoing a sudden change and will require this challenge to be tackled in a different way to the recent past.
“We believe that a driver pairing with the talent and personality of Charles and Carlos, the youngest in the past 50 years of the Scuderia, will be the best possible combination to help us reach the goals we have set ourselves.”
Sainz is awaiting the start of his sixth season in F1 and his second with McLaren, having joined the British team in 2019.
He made his F1 debut in 2015 with Toro Rosso before joining Renault towards the end of the 2017 season, where he remained before being scooped up by McLaren.
“I am very happy that I will be driving for Scuderia Ferrari in 2021 and I’m excited about my future with the team,” he said.
“I still have an important year ahead with McLaren Racing and I’m really looking forward to going racing again with them this season.”
Bahrain International Circuit - Winter testing