South America’s Olympic debut ended Sunday night doused with a tropical drizzle but dancing all the way, a festive Brazilian farewell to a zany 17 days of brilliant athletic performances served with a sideshow of mishaps and scares.

The world’s athletes, shrouded in plastic ponchos and smiling through the rain, seemed an apt ending to an Olympics that was always an uphill climb. With dancers dressed as colorful birds, fiddlers and fireworks, Rio drummed and stomped its way to a happy, sopping, final note before passing the baton to Tokyo, the next host city, and more artificial rain doused the torch.

The crowd that braved the wet and blustery evening, and it was far from full at Maracanã Stadium, celebrated with Brazilian regional song and dance, electronica, samba and marching tunes.

Brazil’s portion of the Closing Ceremonies had a natural, handmade feel: fruit and feathers, cave paintings and dancers forming craftwork lace. The only departure from the upbeat mood came when the mayor of Rio, Eduardo Paes, was greeted onstage with boos.

Carlos Arthur Nuzman, the president of the Rio Olympic Committee, told the crowd that hosting the Games in Rio was a “great challenge,” but one that was met with success.

Fans from around the world gathered in Maracana stadium to celebrate the end of the tumultuous 2016 Rio Olympic Games on Aug. 21. (Reuters)

“This is still a magic place,” he said.

The Japanese segment went with sleek urban scenes and illuminated cubes. Super Mario burrowed through the earth and popped up in Maracanã in the form of Japanese Prime Minister Shinzo Abe.

Brazilians’ boisterous passion, their full-throated cheers and boos, their warmth and hospitality were the only constants in a roller-coaster competition in which it was hard to know where to look: at the weeping Neymar as national hero, the inspiring Usain Bolt in his last lightning pose, or the drunk American swimmers vandalizing a gas-station wall. For the home team, the Games felt somewhat redeemed by late wins, taking golds in soccer and volleyball, Brazil’s favorite sports. The Olympics brought many Brazilians together in a welcome distraction from the country’s difficulties, replaced by two weeks of national pride.

Every day, fans by the thousands, a human sea tinted with many Brazilian greens and yellows, streamed into Olympic Park by walking down a makeshift ramp balanced on scaffolding and next to a canal of raw sewage. They waited in miles of lines in punishing sun to get searched by security or order an overpriced frozen pizza. On the rainy days, they shrugged and put on their slickers.

There was no president to sum up these Olympics in stirring words. One was awaiting her impeachment trial, and the stand-in has stayed far from the stadiums since being drowned out by boos at the Opening Ceremonies.

But on a drizzling Saturday afternoon there was Vinicius Machado, a 24-year-old IT infrastructure planner for the federal government, who was drinking a beer at a picnic table in Olympic Park. Maybe these Games were not as seamless as in London or Beijing, he said, but Brazilians got it done, and those who came had a good time.

“We are a nice, friendly people. So we were anxious about this event,” he said. “We were testing ourselves.

Brazilians watch the second half of the Brazil-Germany soccer match on Aug. 20 where the host country won its first gold medal in the sport. (Mario Tama/Getty Images)

“We had some problems; we had some situations with the Americans,” he added. “But we did it our way, and we did well, I think.”

For others, this Olympics was unpopular, even infuriating, and can also be judged by who did not attend. Rio is an unequal city, and the less fortunate often were bulldozed out of the way or priced out of events. Tens of thousands of families, a good number of them the poor in favelas, were evicted to pave the way for expensive Olympic projects. Half of Brazil is black or mixed race, and while black athletes such as judo star Rafaela Silva won medals for Brazil, blacks were conspicuous by their absence in the stands.

“I have no time to follow [the Olympics],” said Jefferson Nascimento, 25, who was serving juices and snacks to the crowds flowing through Rio’s busy Central Station, some of whom were off to Olympic events. “I don’t think it’s a success.”

The past few years have been difficult for Brazil: a painful recession, protests in the streets, violence on the rise, enough chaos and belt-tightening that many doubted whether it was worth hosting an expensive athletic event.

“Rio already has difficulties with money, and this Olympics made it worse. It was good to have the Games, but this was not the right moment,” Paloma Resende, 16, said in the stands at the women’s field hockey final. “After the Olympics, it will get worse.”

Brazilians showed wild enthusiasm for some Olympic stars. In these Games, Michael Phelps cemented his status as the most decorated Olympian in history, wearing more gold than anyone, besting competitors a decade younger and breaking a record set more than 2,000 years ago. Another coronation went to Bolt, the greatest sprinter who ever lived, capping his third straight Olympics with three straight golds and a stadium of fans chanting his name. And new superstars were born after the utter athletic dominance by a pair of 19-year-olds, swimmer Katie Ledecky and gymnast Simone Biles.

The host city could claim some wins. Many praised the new subway line, the bus rapid-transit lanes that zipped fans from venues many miles apart, and the redeveloped port area, anchored by the new Museum of Tomorrow.

But the bad and bizarre came in waves. A stray bullet here, body parts on a beach there. Whenever one problem was solved, another popped up. The green water in the diving pool was drained and refilled to its intended blue, just in time for an overhead television camera to crash into the park, the whiplash from its cable injuring fans. Suspicious backpacks were blown up, and a media bus was attacked. About 6 million people bought tickets, more than 90 percent of those available. But empty seats dogged events throughout the Games. About 11 percent of tickets sold to the general public were not used, organizers said.

In one ring of the Olympic circus, boxing judges were sent home for questionable calls; in another, the head of the Irish Olympic Committee was arrested for scalping tickets and locked up in a Brazilian prison. Team Russia was devastated by doping scandals, a stain that has tainted many countries in this and other Games. When there weren’t high-level security officials, ministers, athletes and coaches being robbed at gunpoint, there was American swimmer Ryan Lochte lying about having a gun held to his head and his three teammates going along with the ruse.

For Brazil, the conclusion to that tabloid saga felt like a bit of redemption, as it was their much-disparaged police who investigated the case and got to the truth.

“I think you have enough proof now that they lied, which is a shame,” said Maria da Silva, 52, a skin-care specialist who is Brazilian by birth but has lived for the past three decades in the United States. “But justice has been served.”

Silva, wearing a USA shirt in the stands to watch the U.S. men’s basketball team play Spain, had been disappointed that so many people, Brazilians and foreigners alike, had been scared away from the Olympics by the warnings about the Zika virus and crime.

“A lot of people expected negative stuff. But it’s been fantastic,” she said. “I’m going to be missing it when it’s over.”

Mariana de Castro, 31, came to Rio from São Paulo, renting a room not far from Ipanema Beach, and signed up to be a volunteer for the Games. She was assigned the tennis courts, where she was wowed to see Secretary of State John F. Kerry and a prince from Denmark. Her friends had questioned why she would attend the Olympics, with the risks and potential problems.

“People were telling me, ‘Oh, you’re going to the Olympics? What about terrorists?’ ” she said. “This is going to be part of Brazilian history. I wanted to be part of it.”

The Brazilian national sporting heart has only one true love, soccer, so much was riding on Saturday night’s gold-medal match between the host country and Germany, which tore out Brazil’s heart two years ago in a 7-1 slaughter in the World Cup tournament. Winning the rematch was all they might need to consider this Olympics a success. It took a penalty shootout to win, and the man who did it, Brazil’s limping star Neymar, looked as if he was crying even before his last shot hit the net.

“This eases some of the pain,” said Paulo Hemman, 47, who was savoring the win at a Santa Teresa bar. “The game is a relief from everything that happened, to de-stress. The game makes us forget.”

Read more

On Rio streets, Neymar’s goal for Olympic gold means celebration — and relief

For the displaced of Rio, ‘The Olympics has nothing to do with our story’

Police discredit Ryan Lochte’s robbery story, say swimmers owe Rio an apology

Today’s coverage from Post correspondents around the world