The match, Ronaldo's first appearance for Portugal on the island where he was born, took place on the eve of a ceremony to name Funchal airport after the 32-year-old Real Madrid forward, giving the whole evening a testimonial feel.
But the celebrations turned to misery for the 10,000 crowd as Joao Cancelo put through his own goal in stoppage time to hand Sweden an unlikely victory against the European champions.
The first half went entirely to script as Ronaldo, whose last professional match in Madeira was a league game with Sporting in 2003, turned in Gelson Martins' cross after 18 minutes for his 71st international goal.
Ronaldo volleyed narrowly wide before again combining with Martins, whose pass was turned into his own net by Sweden captain Andreas Granquivst in the 34th minute.
Portugal were fielding an experimental team and Sweden, who had already exploited some gaps in the defence during the first half, pulled one back through Viktor Claesson in the 57th.
Read the full article on eurosport.co.uk: Ronaldo scores homecoming goal but Sweden wreck the party