The list of African qualifiers was completed with Ghana advancing 7-3 on aggregate over Egypt despite a 2-1 loss in Cairo and Algeria progressing on away goals at the expense of Burkino Faso. Nigeria, Ivory Coast and Cameroon had already won their playoffs.
The final two berths for the 32-team World Cup will be secured on Wednesday, with Uruguay protecting a 5-0 lead over Jordan and Mexico 5-1 up on New Zealand heading into the second legs of their intercontinental playoffs. The draw for the group stage of the 2014 World Cup takes place in Bahia, Brazil, on Dec. 6.
Spain endured a miserable return to the scene of its World Cup triumph in 2010, losing 1-0 to South Africa at FNB Stadium the venue formerly known as Soccer City in one of a host of international friendlies.
A virtually second-string Germany team consigned fierce rival England to back-to-back losses at Wembley Stadium for the first time in 36 years by winning 1-0, and Netherlands played with 10 men for almost an hour but still drew 0-0 with Colombia.
While France was engineering the greatest recovery of the playoffs, Ronaldo proved once again he is the man for the big occasion, continuing a prolific season in which he could yet wrestle the World Player of the Year award from great rival Lionel Messi.
He had already trumped Ibrahimovic by scoring the winner in the first leg on Friday, but the rivalry between arguably the two biggest showmen in the sport climbed to new levels at the Friends Arena.
Ronaldo opened the scoring in the 50th minute but Ibrahimovic netted twice in four minutes to level the score on aggregate and give Sweden hope. That was quickly extinguished by two pieces of brilliance from Ronaldo, who burst through to power home a left-footed in the 77th before latching onto another through-ball and smashing into the roof of the net two minutes later.
"Of course, we cannot underestimate how important is Cristiano for us," Portugal coach Paulo Bento said.
His second hat trick in international football, to go with his 24 at club level for Manchester United and Real Madrid, sparked jubilant scenes of celebration as Portugal's coaching staff and substitutes spilled onto the pitch.
That was possibly the last chance for the 32-year-old Ibrahimovic to play at a World Cup, but football fans will be thrilled that both Ronaldo and France's Franck Ribery two of the favorites for this year's Ballon d'Or will be in Brazil.
Ribery took a back seat on Tuesday as Benzema and, more surprisingly, central defender Sakho ushered 1998 world champion France to next year's tournament.
Didier Deschamps lifted the World Cup in the Stade de France 15 years ago in his finest moment as a player and this fightback, against a Ukraine lineup known for his doughty defense, probably tops his achievements as a coach.
"I've experienced some great moments but this one is special. It's fabulous," Deschamps said.
France leveled the aggregate score at 2-2 by halftime through close-range goals by Sakho and the recalled Benzema before Ukraine was reduced to 10 men in the 47th when fullback Yevhen Khacheridi was red-carded for fouling Ribery. Worse was to follow for the visitors as substitute Oleg Gusev turned a driven cross into his own net under pressure from Sakho, putting the French through.
"We took a big slap in Ukraine," Ribery said, "and we woke up."
Croatia qualified for its fourth World Cup since becoming an independent state in 1991 and quashed Iceland's hopes of reaching football's showpiece tournament for the first time.
Striker Dario Mandzukic scored in the 22nd minute to put Croatia ahead on aggregate but was given a red card nine minutes later for a reckless tackle. Iceland, whose population is only around 320,000, couldn't capitalize and Darijo Srna's 47th-minute goal sealed victory for the hosts.