Daniel Ricciardo is to race for McLaren in 2021, taking the seat of Carlos Sainz, who will move to Ferrari.
The double switch was announced by both teams on Thursday morning in a choreographed series of news releases.
Ricciardo will partner Lando Norris, while Sainz is to replace four-time champion Sebastian Vettel at Ferrari.
McLaren Racing chief executive officer Zak Brown said Ricciardo brings "an exciting new dimension to the team"; Ferrari said Sainz was "the ideal fit".
Ferrari team principal Mattia Binotto added that Sainz "had proved to be very talented and has shown that he has the technical ability and the right attributes".
Vettel's departure from Ferrari at the end of this season was confirmed on Tuesday.
- Vettel to leave Ferrari at end of season
- Could Vettel's Ferrari frustration lead to retirement from F1?
Ideal support for Leclerc
McLaren had to release Sainz from his contractual obligations to the team before he could join Ferrari - the team had an option on the 25-year-old Spaniard for 2021.
And they needed to secure Ricciardo's signature before that happened.
Ferrari have identified Sainz as the ideal support for Leclerc, whose starring performances in his first season with the team last year undermined Vettel's status and precipitated his departure when he was not prepared to accept diminished contractual terms. Leclerc signed a five-year deal until 2024 over the winter.
Ferrari, who say they have signed Sainz on a two-year deal, will envisage the Spaniard in the type of back-up role Valtteri Bottas plays to Lewis Hamilton at Mercedes - quick enough to be close to him and engage in battle with other front-runners but unlikely to be a consistent challenge.
Binotto added: "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, who previously drove for Toro Rosso and Renault before moving to McLaren last year, is likely to view the move as an opportunity to prove himself as a top-line driver.
Sainz said he was "excited about my future" with Ferrari but "looking forward to the season ahead with McLaren".
Sainz excelled in his first season with McLaren last year and his strong race performances have earned him the call-up from Ferrari.
The domino effect in the driver market was triggered when negotiations over a new contract between Ferrari and Vettel failed.
Ferrari announced on Tuesday that the German four-time world champion would be leaving the team at the end of the 2020 season, which is currently on ice as a result of the coronavirus crisis.
McLaren's major coup
Ricciardo came close to joining McLaren in 2019 when he left Red Bull, but in the end chose Renault because they were more competitive at the time.
But the two teams' fortunes diverged last year, with McLaren jumping up the grid and Renault's progress back towards the top stalling; in fact they fell behind McLaren to finish fifth in the championship.
Ricciardo has now decided that McLaren are a better bet for the future - a decision partly influenced by their switch to Mercedes engines for the 2021 season.
That is one of a number of significant decisions made by new team principal Andreas Seidl, who has impressed with his no-nonsense, get-on-with-it approach since joining the team in May last year.
"Signing Daniel is another step forward in our long-term plan and will bring an exciting new dimension," said Brown.
"I also want to pay tribute to Carlos for the excellent job he has been doing for McLaren in helping our performance recovery plan. He is a real team player and we wish him well for his future beyond McLaren."
Signing the 30-year-old Australian, a seven-time winner with Red Bull between 2014 and 2018, is a major coup for McLaren, who last year made impressive progress back to fourth in the championship after a dismal few years falling down the grid.
Seidl said: "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. With Daniel and Lando as team-mates, I believe we have two racers who will continue to excite our fans and help the team grow."
Who will replace Ricciardo?
Ricciardo's departure leaves a space at Renault alongside Frenchman Esteban Ocon, assuming the car manufacturer stays in F1 next year.
Renault are said to be keen to promote one of their young drivers to the role if they are deemed ready but both Vettel and double world champion Fernando Alonso are contenders.
Renault is considering Alonso as an option but is understood not to be close to a decision on Ocon's partner in 2021.
Alonso said at the end of last year that he would consider a comeback to F1 after two years out, but he will have to weigh up whether he believes Renault will give him the competitive car he says he wants.
But he has fond memories of the team, having won both his world titles with them in 2005-6. He also returned there for a two-year period in 2008-9 after his move to McLaren turned sour in a tumultuous year alongside Lewis Hamilton in 2007 and before moving to Ferrari.
He has said he views the new regulations being planned for F1 as a chance for the field to be more competitive.
But these have now been delayed a year until 2022 as part of a package of changes to cut costs because of falling revenues from the truncated 2020 season.
That means Alonso - who turns 39 this July - would have to be prepared for a 2021 season likely in the upper midfield and it remains to be seen if he wants to go through that again after his five years in an uncompetitive McLaren from 2015-18.
Of the Renault young drivers, Dane Christian Lundgaard and their Chinese reserve driver Guanyu Zhou are furthest up the ladder in Formula 2 this year.
They also have a British driver in Formula 3 on their books - Max Fewtrell.
Of these, Lundgaard is said to be held in the highest regard within Renault and closest to a potential F1 move.
However, it is remains to be seen whether any of the three are considered ready for promotion to F1 next year, a decision made more difficult by the curtailment of racing this year as a result of coronavirus.