An extra-time winner saw the United States beat Brazil 2-1 to win gold in the women's football tournament.
Abby Wambach's header from a corner in the 112th minute secured the Americans their second Olympic title, after victory in 1996 and silver in 2000.
They had led through Lindsay Tarpley's opener six minutes before half-time.
But Pretinha equalised in the 73rd minute and Brazil twice nearly had a winner in normal time when Cristiane and Pretinha both hit the post.
Instead, the United States prevailed when Wambach rose to powerfully head home Kristine Lilly's corner eight minutes from time.
It was an emotional night for US captain Mia Hamm, who announced her retirement from competitive football at the age of 32.
Hamm was the outstanding player of her generation, winning more than 200 international caps in an illustrious 17-year career.
Germany won the bronze medal match with a 1-0 victory over Sweden.
Renate Lingor's shot after 17 minutes - that slipped through the fingertips of Swedish goalkeeper Caroline Joensson - proved to be the only goal.
Germany were grateful to their own keeper Silke Rottenberg, who made a string of superb saves to keep Sweden at bay.
Germany could have won by a bigger margin but Conny Pohlers blazed a great chance wide from Birgit Prinz's cross.
Germany lost their semi-final 2-1 in extra-time to the United States, while Brazil beat Sweden 1-0 in the other semi.