Sweden did it again, this time against the hosts.
The Swedes are headed to the gold-medal match at the Olympics for the first time, advancing 4-3 on penalties after a scoreless draw with Brazil on Tuesday.
Brazil forward Marta, one of the biggest stars of the tournament, buried the first kick of the shootout. But at 3-3, Sweden goalkeeper Hedvig Lindahl stopped Andressa's shot before Lisa Dahlkvist beat Barbara to end it, stunning the packed home crowd at the Maracana Stadium.
Sweden has now won two straight penalty shootouts. In the quarterfinals, the Swedes beat the United States, knocking the Americans out of medal contention for the first time.
Sweden will next face either Germany or Canada in the final on Friday at the Maracana, the site of the men's World Cup final in 2014. Brazil will play for the bronze against the loser of the other semifinal match in Sao Paulo.
Marta had one of Brazil's best chances, but her free kick in the 115th minute bounced before the goal and Lindahl was able to snag it.
The fans at the nearly filled 78,000-seat Maracana — the biggest crowd ever for a women's national team match in Brazil — roared whenever Marta touched the ball. Brazil's charismatic forward won FIFA's Women's World Player of the Year five consecutive years from 2006-10. But she has never won a major international tournament with her national team.
One fan lofted a sign that said "Marta We Love You."
Both teams had their chances in the opening 90 minutes, and the intensity rose as the defensive-minded Swedes started going on the attack more.
Sweden was riding high after knocking off the three-time defending champion United States in the quarterfinals. The loss sent the top-ranked Americans home without a medal for the first time since women's soccer joined the Olympics in 1996. The World Cup champions were vying for their fourth straight gold.
Sweden deployed a defensive strategy against the United States and advanced 4-3 in a penalty shootout after a 1-1 draw in Brasilia. Afterward, U.S. goalkeeper Hope Solo drew attention for calling Sweden "a bunch of cowards" for its style of play.
Sweden coach Pia Sundhage used a similar tactic against Brazil, changing her approach after losing to Brazil 5-1 in group play. Marta and Beatriz scored two goals each in that first match.
The Brazilians have twice won silver medals at the Olympics. Both times, at the 2004 Athens and 2008 Beijing Games, the United States won in the final.
Sweden's best finish was in Athens when the team fell to Germany in the bronze medal match. Brazil beat Sweden 1-0 in the semifinals at those Olympics.