The Springboks and Spain have played only once before, at the RWC in 1999, when South Africa won their pool game at Murrayfield in Scotland by 47-3.
On that occasion, 10 October 1999, Andre Vos captained the Boks and scored two of their six tries, with Anton Leonard, Werner Swanepoel, Pieter Muller and Bob Skinstad also dotted down. Jannie de Beer converted six of the five-pointers, while the Boks were also awarded a penalty try.
"It's been a long journey and a very tough qualification process," said Spain head coach Santiago Santos.
"We lost our first three games and after that, we have won six in a row.
"The performance of the team was amazing and we are very excited to be going to the Rugby World Cup."
Los Leones’ RWC 2023 will get underway on Saturday, 9 September 2023 when they take on Ireland at Stade de Bordeaux.
Eight days later, Santiago Santos’s side will face the Springboks at the same venue, before heading to Lille where they play Scotland on 30 September and the Asia / Pacific 1 qualifier on 8 October.
Spain’s last tournament appearance came at RWC 1999, where they were also drawn alongside South Africa and Scotland, as well as Uruguay, in Pool A.
Los Leones lost each of their three matches, all of which were played in Scotland, as they exited the tournament at the pool stage.
Victory at Estadio Nacional Universidad ensures Spain will finish second in the combined Rugby Europe Championship 2021 and 2022 standings no matter the result of their final match against Georgia next Sunday.
It caps a stunning turnaround for Los Leones, who began their RWC 2023 qualification campaign with three successive defeats at the start of last season’s Rugby Europe Championship.
Santiago Santos’ side have since won six Championship matches in a row to set up both a title decider against Georgia in Tbilisi next weekend and take their place as the Europe 2 qualifier at RWC 2023.
Los Leones will end a 24-year wait for a second Rugby World Cup appearance when they make the short trip to France next year, where they will line up in Pool B alongside Webb Ellis Cup holders South Africa, Ireland, Scotland and the Asia / Pacific 1 qualifier.
Spain and Portugal served up a match fitting of the occasion on Sunday, the Iberian rivals giving everything they had got in front of a big and vocal crowd who were bathed in bright sunshine throughout.
Portugal's ever-reliable kicker Samuel Marques opened the scoring with a penalty but big tight-head Jon Zabala had the crowd on their feet when he raced home from 25 metres out.
However, Los Leones failed to deal with the restart and from possession inside the home side's 22, Portugal worked a try for full-back Simão Bento in the left-hand corner, Marques converting for a 10-5 lead.
Having been shown the way by Zabala, Spain's forwards took it upon themselves to wrestle back control of the scoreboard and flanker Fred Quercy and Marco Pinto rumbled over from close range.
Unperturbed by the double blow, Portugal worked some good field position and managed to convert possession and territory into points when Pedro Bettencourt hit the line at pace and crashed over.
But the final word of an exhilarating half went to Spain as Pinto continued his fine try-scoring streak with his second and sixth in as many games just before half-time. With Manuel Ordas' second conversion, Spain led 24-17.
The second half did not quite live up to the first in terms of the fluency of the play but the tension of the occasion still made it a gripping watch as Manuel Ordas and Samuel Marques traded penalties in the third quarter.
Leading 33-23, Spain came under intense pressure in the final 10 minutes and after giving away a succession of penalties and losing Charlie Melie to a yellow card, they conceded a try in the corner to second-row José Madeira.
With only 19 seconds left on the clock, Portugal declined the conversion in an attempt to give this brilliant advert for the Rugby Europe Championship a grandstand finish.
Portugal claimed the restart but after a few desperate phases in their own 22, they were penalised by French referee Tual Trainini for holding on and the joyous scenes of celebration started for everyone in red
While Portugal need the Netherlands to do them a favour at home to Romania on 19 March to claim third place and make it to the Final Qualification Tournament, Spain's place at France 2023 is now confirmed.