RIO DE JANEIRO (Reuters) - Host nation Brazil, backed by an emotional and enthusiastic local fan base, captured the most Olympic medals in the country's history but fell far short of the haul that past host nations have brought in.
Brazil's 19 medals, seven of them gold, was a significant improvement over its London 2012 performance, more than doubling the number of golds and picking up two more medals in total.
The country's tally was capped off by a gold in the men's volleyball finals on Sunday and Brazil's first men's soccer gold on Saturday.
For the crowds that poured into the streets to celebrate the soccer win, or shouted from windows and in bars throughout a rainy Rio during the volleyball final on Sunday, the victories were another sign that a Games many once thought destined for disaster had far exceeded local expectations.
From concerns about the Zika virus, to polluted waters, security and shortages of funds, the Rio Games faced problems that critics believed could derail their success.
"I can't tell you how happy I am, and I've been a critic of the games" said Rafael Rocha, 28, a designer out celebrating Brazil's soccer gold in the early hours of Sunday. "Not only have the games gone well, Brazil is doing well too. This is a huge relief."
Brazil could also celebrate an Olympic record pole-vault victory, gold in men's beach volleyball and women's sailing 49erFX class.
That 49erFX win, and the willingness of nearly all sailing medalists to jump into the water to celebrate, seemed to belie concerns that the dirty waters of Guanabara Bay were too polluted to sail in.
Though Brazil's medal performance impressed some here, it also fell short on a range of measures. Sports in which Brazil was supposed to perform well in, such as Judo, were a disappointment. And athletes expected to win medals in events ranging from sailing to gymnastics failed to get on the podium.
As a result, Brazil came in 13th in the gold-medal table and 12th in total medals, missing the government's goal of a top-10 finish in the over-all medal count. Only hosts Canada in 1976, Mexico in 1968 and Greece in 2004 have done worse, and all have far smaller populations.
Kenya and Jamaica were two of the smaller and poorer countries that came close to Brazil in the gold-medal race, finishing 15th and 16th, respectively.
As the cheering dies down, questions will linger about why a country so large and relatively rich is such an underperformer at the world's premier sporting event.
Many medal winners called on the government to spend more on sports. Brazilians frequently complain that schools and universities have small sports programs, if any.
"I'm thrilled, but we really are not performing at the level our country is capable of," said musician Ivan Britz, 30, during the street parties for Brazil's soccer gold.
Reporting by Jeb Blount; Editing by Andrew Hay