Ferrari said 25-year-old Sainz, who replaces four times world champion Sebastian Vettel alongside young Monegasque Charles Leclerc at the sport’s most glamorous team, had signed for 2021 and 2022.
Vettel’s departure at the end of a season so far stalled by the Covid-19 pandemic was announced on Tuesday, with the German’s next move uncertain.
“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,” said Ferrari principal Mattia Binotto.
The move also ends speculation about Lewis Hamilton’s future, with the 35-year-old Briton now sure to stay at Mercedes as he chases a seventh title to equal Michael Schumacher’s record.
Ricciardo will depart Renault after opting for McLaren, the former world champions he rejected in 2018 when leaving Red Bull.
“Signing Daniel is another step forward in our long-term plan and will bring an exciting new dimension to the team, alongside Lando,” said McLaren Racing CEO Zak Brown, announcing a multi-year arrangement.
The Australian, a seven times race winner with Red Bull, will be the experienced man alongside 20-year-old Briton Lando Norris, with McLaren also switching from Renault to Mercedes engines in 2021.
Ferrari will be Sainz’s fourth employers after a 2015 debut with Italy-based Toro Rosso, followed by stints at Renault and McLaren.
Remarkably, he was not the first choice for any of his first three teams until landing one of the most coveted seats on the grid.
Sainz has just one career podium finish, a third place in Brazil last season that was McLaren’s first since 2014 and helped them finish the year fourth overall.
He will now follow in the footsteps of boyhood hero, friend, compatriot and double world champion Fernando Alonso, who also went from Minardi (Toro Rosso’s predecessors), to Renault, McLaren and Ferrari.
The 38-year-old Spaniard, who left Formula One at the end of 2018, is now being linked in media speculation to a return to Renault.
Renault said they were in no hurry to name a replacement.