After announcing on Tuesday that Vettel would be leaving the team at the end of the season, Ferrari moved swiftly to strike a deal with Sainz as his replacement.
Ferrari issued a statement on Thursday morning confirming Sainz would be joining the team from McLaren for the 2021 season, partnering Charles Leclerc.
Ferrari said Sainz had signed a two-year deal.
"I am very happy that I will be driving for Scuderia Ferrari in 2021 and I'm excited about my future with the team," said Sainz. "I still have an important year ahead with McLaren Racing and I’m really looking forward to going racing again with them this season."
"I'm pleased to announce that Carlos will join Scuderia Ferrari as from the 2021 championship," said Ferrari team principal Mattia Binotto.
"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 fifty years of the Scuderia, will be the best possible combination to help us reach the goals we have set ourselves."
McLaren confirmed earlier today that Sainz would be leaving the team at the end of the year after the signing of Daniel Ricciardo, whose own departure from Renault was also confirmed in a flurry of announcements.
Sainz was one of the breakout stars of the 2019 season as he finished sixth in the championship for McLaren, scoring the team's first podium in almost six years at the Brazilian Grand Prix.
McLaren had already opened talks with Sainz over a new contract beyond 2020 as he entered the second year of his two-year deal, but negotiations had not advanced to a late enough stage to fend off interest from Ferrari.
It marks the latest big step for Sainz in an F1 career that has accelerated rapidly in the last three years since his departure from Toro Rosso.
Promoted to F1 alongside fellow Red Bull junior Max Verstappen in 2015, Sainz spent almost three seasons with Toro Rosso before joining Renault with four races left in the 2017 campaign.
Renault's deal to sign Ricciardo left Sainz without a drive for 2019, only for McLaren to pick up the Spaniard on a two-year contract.
Sainz quickly adjusted to life with McLaren, forging a good relationship off-track with rookie teammate Lando Norris, and was able to lead the team on-track as it recorded its best constructors' championship finish since 2012.
As talks broke down with Vettel, Ferrari quickly identified Sainz as the driver it wanted to partner Leclerc for the future, allowing the deal to be announced just 48 hours after Vettel's departure was made official.