Sainz, 25, will leave McLaren following the 2020 season to partner 22-year-old Charles Leclerc at Ferrari, forming the team's youngest pairing in the past 50 years.
"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," Ferrari team boss Mattia Binotto said in a statement on Thursday.
"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," he added, referring to the additional challenges created by the coronavirus pandemic.
"We believe that a driver pairing with the talent and personality of Charles and Carlos... will be the best possible combination to help us reach the goals we have set ourselves."
Sainz emerged in pole position to succeed Vettel at Maranello after the German announced Tuesday he was quitting Ferrari after talks over a new contract broke down.
Sainz, whose father, also Carlos, is a two-time world rally champion, has previously driven for Red Bull's feeder team Toro Rosso and Renault before impressing with McLaren last season.
He secured the once all-conquering British team's first podium place in almost six years in Brazil last year.
Signing Sainz will also end any lingering speculation about six-time champion Lewis Hamilton leaving Mercedes for Ferrari.
"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."
Australian Ricciardo will drive for McLaren next season when he takes over the seat left vacant by Sainz.
Ricciardo, 30, will line up alongside Britain's Lando Norris, 20, in 2021 after he leaves Renault at the end of this season.
"Daniel is a proven race-winner and his experience, commitment and energy will be a valuable addition to McLaren and our mission to return to the front of the field," said McLaren team principal Andreas Seidl.
"With Daniel and Lando as teammates, I believe we have two racers who will continue to excite our fans and help the team grow."
Ricciardo has won seven races and recorded 29 podium finishes since his F1 debut with the HRT team at the British Grand Prix in 2011.
He drove for Red Bull's junior team Toro Rosso in 2012 and 2013 before making the jump to the flagship Red Bull team in 2014. He finished third in the drivers' standings in 2014 and 2016.
However, he failed to muster a single top-three finish in his first season at Renault.
After the first 10 races of the coronavirus-hit 2020 campaign were either cancelled or postponed, Formula One hopes to open its season in Austria with back-to-back races on July 5 and 12.
F1 chief Chase Carey last week insisted a 15-18 race season was still possible, but he admitted that all scenarios are on the table "including the remote possibility of no racing in 2020".