Brazil had thrashed the Swedes 5-1 in the group stages just 10 days ago, but were held to a third consecutive 0-0 draw and, as in their quarter-final win over Australia, forced to go through the agony of penalties.
Unlike against the Aussies, five-time World Player of the Year Marta did convert from the spot, but was reduced to tears as her ambition of capping a glorious career by finally winning a major international title fell short of the final. "There is no way to describe the feeling of frustration," said Brazil coach Vadao.
Shaunae Miller dives for gold at Rio Olympics
Marta, who has played her club football in Sweden for the past four years, was consoled by the Swedish players, whilst a huge crowd in excess of 70,000 at the iconic Maracana stadium gave their defeated team a huge ovation.
Cristiane, the Olympics' all-time top scorer, and Andressa saw spot-kicks saved by Hedvig Lindahl after neither side could score a goal in 120 minutes.
Lisa Dahlkvist converted the winning penalty to secure a place in the final and Sweden's first women's football Olympic medal.
Germany also avenged a group stage defeat in the other semi-final as goals from tournament top scorer Melanie Behringer and Sara Daebritz confined Canada to a 2-0 defeat and another battle for the bronze they won in London four years ago against Brazil in Sao Paolo on Friday.
How former national women hockey captain's Olympic dream came true
Brazil's women were playing for just the second time at the iconic Maracana and Vadao hopes the momentum built-up for the women's version of the game in football-mad Brazil is not halted by the disappointment. "This is a glorious moment for women's football. It is everybody's dream to play here," added Vadao.
"It is full of tradition. It is a cultural thing in Brazil, it is a symbol. Maracana means Brazil and Brazil means football. It is quite a moment and I am just sorry we didn't make it to the final."
By contrast, there was delight for Sweden coach Pia Sundhage, who now has the chance to win a third straight gold medal after leading the USA to victory in 2008 and 2012. "It is very emotional. I have been in China and London in Olympic finals, but with a team everyone expected to do well.
"The road we have taken has been different, a wonderful trip with one or two upsets."
Sweden's hero Lindahl described the baking sun in Salvador during the Scandinavians' shock quarter-final win over three-time defending gold medallists the United States on penalties as "her enemy".
Lindahl suffers from vitiligo, a condition that causes patches of skin to lose their pigment, making the skin particularly sensitive in the sun.
And she was under fire in the Rio heat as a flurry of early Brazilian attacks peppered the Sweden goal.
Lindahl even had to endure chants of "Zika" from the home fans, which had been previously reserved for outspoken USA 'keeper Hope Solo.
Marta inspired the 5-1 thrashing of Sweden with two goals in the group stage, but despite their dominance the ball wouldn't go in for the hosts as Marta, Beatriz and Debinha all came close.
Solo had castigated Sweden as "cowards" for their defensive display in the last eight, but that seemed to only strengthen the resolve of Sundhage's women as they barely threatened the Brazilian goal. "It is not for me to criticise the opponent, especially because their strategy worked and they had good results in both matches," said Vadao graciously.
Vadao introduced Cristiane for extra-time despite doubts over her fitness after missing the quarter-final through injury.
That gamble backfired, though, as she couldn't add to the 14 goals she has scored across four Games from the spot and, when Lindahl parried Andressa's effort, Dahlkvist coolly slotted home to silence the Maracana.
COMMENTS
Comments are moderated and generally will be posted if they are on-topic and not abusive.
For more information, please see our Comments FAQ