The game didn't live up to its billing as the marquee matchup of the European playoffs, though, especially in a mostly dull second half.
The Swedes looked happy with what looked likely to be a draw, and the Portuguese once again looked mediocre going forward until Ronaldo struck.
There was no fancy footwork from Ronaldo, and no jaw-dropping shots out of the blue from Ibrahimovic who, as a lone striker in a defense-minded team, had little impact.
"We knew it would be close," Portugal coach Paulo Bento said. "We've now got to go and win in Sweden. We won't be playing defensively there."
This is the third time in a row Portugal has fallen short of automatic qualification for a major international tournament. It also went through the playoffs to reach the 2010 World Cup and Euro 2012.
Sweden lost its unbeaten record in Portugal after seven previous unbeaten visits.
The game started brightly, as Joao Moutinho ran into the Swedish area to meet a Raul Meireles pass and rounded goalkeeper Andreas Isaksson before the shooting angle became too tight.
Immediately after, the Swedes caught the home defense napping, with Mikael Lustig crossing from the right for Johan Elmander to poke the ball just wide.
The 61,000 home crowd roared in anticipation after 15 minutes when Rasmus Elm fouled Ronaldo close to the penalty area, setting up the Real Madrid striker for one of his trademark free kicks. Sweden pulled every man into defense but Ronaldo blasted his shot against the wall.
But with Ibrahimovic consuming the attentions of the Portuguese defense, Rui Patricio needed to produce a spectacular save in the 20th, diving sharply to his right to deny Sebastian Larsson from the edge of the area. Kim Kallstrom's curling free kick flew just wide of Patricio's net two minutes later.
Helder Postiga almost cut through the Swedish defense just before the break, and then Isaksson scooped the ball off Postiga's toe from short range.
In a scrappy second half, which occasionally became bad-tempered, a scramble in the Swedish goalmouth almost let in Pepe and Postiga, and Postiga's glancing header scraped the Swedish crossbar in the 62nd.