RIO DE JANEIRO (AP) — Even Germany and Sweden seem to be surprised they are in the women's Olympic soccer final.

Most figured the World Cup champion U.S. national team would be cruising to its fourth straight gold medal. But the Americans were ousted by Sweden in the quarterfinals.

With the United States out, many figured at host Brazil and national star Marta would be playing for gold. But Sweden knocked off the Brazilians, too, this time in the semifinals.

Germany, meanwhile, avenged a loss to Canada earlier in the games, sending the Canadians to the bronze medal match for the second straight Olympics.

So here they are: an all-European Olympic final for the first time. Germany faces Sweden on Friday at the iconic Maracana Stadium, with both making their debuts in the title match.

"This was our dream," Germany defender Annike Krahn said. "It is so difficult to put in words what I am feeling, maybe when we get to Rio and Olympic Village for the first time in the Olympic Games we can celebrate a little bit. But, of course, always focused on the final match."

Germany and host Brazil play in the men's Olympic final on Saturday at the Maracana, marking the first time that a nation has had both its men's and women's teams in the gold-medal match at the same games.

Germany had yet to play in Rio after traveling throughout the country for earlier matches. The Olympic tournament was held in many of the same stadiums in the Brazil that were used in the 2014 men's World Cup, including the Amazonia Arena in Manaus.

Germany has won the bronze medal three times, in Sydney, Athens and Beijing.

"This is amazing. It is the first time for Germany to reach the final and I am very proud about our performance," Germany coach Silvia Neid said. "We improved match by match."

With a win in the final, Neid could cap her career with a championship. The respected coach is stepping down after the Olympics and taking on a scouting role with the German team.

She's facing old friend Pia Sundhage, who has opted for a defensive stance in each of the last two matches — and it has worked. The Swedes advanced on penalties after a 1-1 draw with the United States before a second penalty shootout following a scoreless draw against Brazil.

Sundhage, who coached the Americans to gold medals at both the Beijing and London Games before returning to her native Sweden, seemed nonchalant following the match that relegated host Brazil to the bronze match.

"Yes, we are excited. There is crazy stuff going on in the dressing room," Sundhage said. "The fact that we have done something the Swedish national team has never done before, playing for a medal. It's a big smile."

Germany and Sweden have met three times at the Olympics, and the Germans have won all three — the most recent was a 2-0 victory in extra time in the quarterfinals at the 2008 Beijing Games.

Neither team made the medal round in London.

The Germans defeated Sweden 2-1 on a golden goal in the 98th minute to win the 2003 Women's World Cup, which was held in the United States because of the SARS outbreak in China.