Rio de Janeiro: Germany handed departing coach Silvia Neid the perfect send off by claiming women's football Olympic gold for the first time thanks to a 2-1 win over Sweden in front of a huge crowd at Rio's Maracana.
Dzsenifer Marozsan's sweet strike and Lisa Sembrant's comical own goal put Germany 2-0 up early in the second-half before Stina Blackstenius gave Sweden a lifeline.
Canada beat hosts Brazil 2-1 in Sao Paulo earlier on Friday to claim bronze.
With Brazil's men taking on Germany in their final tomorrow, the boisterous home crowd roared on the Swedes in the final stages.
However, it was to no avail as Sweden boss Pia Sundhage missed out on a third consecutive Olympic title after leading the USA to gold in 2008 and 2012.
Victory handed Neid a golden goodbye in her last game after a hugely successful 11 years in charge, including wins at the 2007 World Cup and 2009 and 2013 European championships.
And she claimed Olympic gold was the greatest of her long list of achievements as German boss.
"Despite the other titles, this is something completely new. This is a new summit for German women's football," said the 52-year-old.
"It is very easy for me to hand over the reigns. It is very different when you take the decision to leave yourself.
"I am looking forward to the future. For 34 years I have been involved in women's football as a player and coach and now I want to do something else and learn other things."
Sundhage, meanwhile, focused on the positives having landed Sweden's first ever women's football Olympic medal.
"After 90 minutes the feeling is a little bit empty, but I said to the players after that we have won a silver medal rather than losing the gold.
"I am so proud not just of the result, but also the way we played today against one of the best teams in the world."
Sweden had been criticised, most notably by outspoken USA goalkeeper Hope Solo, for their defensive tactics in upsetting the world champions and Brazil in the previous two rounds on penalty shootouts.
However, they started on the front foot against the two-time world champions and should have gone in front when Olivia Schough spooned over Lotta Schelin's low cross.
Germany went onto have the better chances in the first-half, though, as Melanie Leupolz headed over from close range before Anja Mittag somehow blasted wide with the goal gaping.
Marozsan showed much more composure with the first opening of the second-half as the Lyon forward curled the ball beautifully into the top corner.
"Dzseny is 24 now and is only getting better as she gets older," added Neid.
"Four years from now she is going to be a grenade and I will enjoy watching her from the stands."
Another Marozsan effort provoked Germany's second as her free-kick came back off the post and Sembrant's panicked clearance sent the ball crashing back into her own goal.
Sweden, having scored just three goals in reaching the final, finally showed their attacking abilities with a well-worked move finished off by Blackstenius five minutes later.
Schough had a huge chance to equalise five minutes from the end, but some frantic German defending finally managed to hack the ball clear.
Canada completed the podium as hosts Brazil lost for the second time in three days to miss out on a medal.
Goals either side of half-time from Deanne Rose and veteran captain Christine Sinclair on her 250th international appearance silenced a passionate crowd and saw Canada defend the bronze medal they won in London four years ago.