The opening 30 minutes were very cagey, with Portugal seemingly happy to sit on their lead and slow play down at the back.
Sweden started full of intent, trying to hurry their opponents into making a mistake, but could barely keep possession for a significant period of time, and Ibrahimovic had to drop further and further back to find the ball.
Portugal grew into the game in the closing stages of the half, with Cristiano Ronaldo having three good chances in the space of 10 minutes, but could not convert any of them.
However, five minutes after the break he opened the scoring, latching onto a through-ball by Joao Moutinho, and he hammered the ball past Andreas Isaksson. That put Portugal 2-0 up on aggregate with an away goal, leaving Sweden needing three goals to progress.
And they almost did it, too. Ibrahimovic gave them hope with a header from a Kim Kallstrom corner, then put them within touching distance of qualification after hammering home a low free-kick from the edge of the area.
Those hopes were dashed by Ronaldo 10 minutes later, however. He again ran onto a brilliant through-ball by Hugo Almeida, and shot low past Isaksson with his left foot.
The Real Madrid forward then put the tie beyond all doubt and completed an extraordinary hat-trick, once again going clean through on goal, taking it just to the left of Isaksson before finishing superbly, despite the presence of two defenders on the line.
Ronaldo will be at the World Cup, carrying the Portugal team on his back as he goes.
50 - GOAL - RONALDO GIVES PORTUGAL THE LEAD - A frantic first five minutes of the half ends when Ronaldo is set clear by Moutinho's great, and he hammers past Isaksson with his left foot.
68 - GOAL - IBRAHIMOVIC GIVES SWEDEN HOPE - Pretty easy for Zlatan, who gets up over Alves, who had a handful of his shirt, to head home from a corner.
72 - GOAL - IBRAHIMOVIC DOES IT AGAIN - The free-kick is right on the edge, just to the right, and Zlatan simply steps up and hammers it low into the bottom corner. Incredible scenes.
77 - GOAL - INCREDIBLE, RONALDO SCORES FOR PORTUGAL - Almeida sets Ronaldo in on goal on the left side of the area, and he buries it into the bottom corner. Remarkable.
79 - GOAL - RONALDO SEALS IT FOR PORTUGAL - Incredible, again. Ronaldo has a hat-trick. A beautiful pass by Moutinho sets him away, he takes it round Isaksson and fires past two defenders on the line. What a player.
Ronaldo has now scored three hat-tricks in his last six games.
Sweden had 62% possession, Portugal 38%
Ronaldo had four of Portgual's five shots on target.
Ronaldo's decent, then? It's something of a shame that voting for the Ballon d'Or has closed, because this performance was almost worthy of the award on its own. A game billed as a battle between two huge egos and absurdly talented players actually panned out that way, with the superior performer coming out on top in a quite spectacular way. Ronaldo was sensational, and was actually unlucky to 'only' score three. Truly remarkable. Of course, we shouldn't forget the superb assists from Almeida and Moutinho, but tonight was about Ronaldo.
MAN OF THE MATCH
Cristiano Ronaldo (Portugal): See above.
Sweden: Isaksson 6, Lustig 6, Olsson 7, Nilsson 5, Antonsson 6, Elm 5, Larsson 7, Kallstrom 6, Kacaniklic 5, Elmander 6, Ibrahimovic 8. SUBS: Durmaz 5, Svensson 5, Gerndt 5.
Portugal: Patricio 7, Pereira 7, Coentrao 6, Pepe 6, Alves 6, Moutinho 7, Veloso 7, Meireles 6, Nani 6, Ronaldo 10, Almeida 7. SUBS: Antunes 6, Carvalho 5, Costa 5.
THE MATCH IN A TWEET