(CNN) -- Cristiano Ronaldo's hat-trick booked Portugal's place at the 2014 World Cup in Brazil as the Real Madrid forward ensured Zlatan Ibrahimovic will be watching the tournament on television.
After two Ibrahimovic goals gave Sweden a 2-1 lead with just 18 minutes left, the 28-year-old scored a quickfire double to turn Tuesday's playoff tie on its head.
Portugal's 3-2 victory in Solna enabled the visitors to qualify as 4-2 aggregate winners.
"I know Portugal needed me in these matches and I showed I am here," Ronaldo told Portuguese TV afterwards.
The hat-trick enabled Ronaldo to become the joint highest scorer for Portugal, level with Pauleta on 47 goals, and to take his recent scoring record to an astonishing 31 goals in 19 games.
The tie had been billed as a battle between Paris Saint-Germain forward Ibrahimovic and Ronaldo, and the latter -- who had scored the only goal in the first leg -- was the clear winner by the end.
Elsewhere, France qualified for the finals after making history with a 3-2 aggregate defeat of 10-man Ukraine.
No European side had ever come back from two goals down to win a World Cup playoff but the 1998 world champions did precisely that when winning 3-0 in Paris.
Strikes from Mamadou Sakho and Karim Benzema gave the hosts a two-goal lead before an own goal from Oleg Gusev in the 72nd minute sealed one of World Cup qualifying's most famous comebacks.
Didier Deschamps was instantly rewarded when the French Football Federation announced that his contract had been extended by two years, meaning it will now finish in 2016.
"It was important for French football to be in Brazil next year -- when we've got all the ingredients we can do great things," the coach told French television.
Croatia, who also enjoyed a memorable 1998 finals when finishing third, booked their place when beating Iceland 2-0 in Zagreb.
Bayern Munich striker Mario Mandzukic opened the scoring but he is set to miss the opening match of the World Cup in June after receiving a straight red card for a reckless tackle.
Dario Srna sealed the win against a nation of 330,000 inhabitants, with the visitors having been in contention to become the smallest nation in history to reach the finals.
The final European playoff was decided by Greece, who drew 1-1 in Bucharest to qualify as 4-2 aggregate winners against Romania.
An early strike by Konstaninos Mitroglou enabled a team that has struggled for goals in this qualifying campaign to comfortably book a place in Brazil.
In Africa, Ghana lost 2-1 in Egypt but the quarterfinalist at South Africa 2010 reached a third straight World Cup by virtue of a dominant first-leg performance, winning 7-3 on aggregate.
Algeria ensured that the same five African teams that had qualified for the last World Cup will be there again, following the weekend qualifications by Nigeria, Ivory Coast and Cameroon.
Trailing 3-2 from last month's first leg in Burkina Faso, the hosts won 1-0 in Blida to qualify on the away goals ruling.
The two remaining places of the 32 were decided on Wednesday.
Mexico secured one of them, beating New Zealand 9-3 on aggregate after a 4-2 victory in Wellington, with striker Oribe Peralta adding a hat-trick to his first-leg double.
Uruguay also went through despite being held 0-0 at home by Jordan in Montevideo, with the 2010 World Cup semifinalist having set up a 12th finals appearance by winning the first leg 5-0 last week.
It was the fourth successive time the two-time world champion had come through the playoffs.
On December 6, the draw to determine the eight groups at next year's World Cup will be held in the Brazilian state of Bahia.