Leonardo Espindola carries the Olympic torch on its way to Rio de Janeiro in Niteroi, Brazil, on Tuesday. The three-month torch relay across Brazil will end at the opening ceremony Friday in Maracana stadium. (Felipe Dana/AP)

RIO DE JANEIRO — With samba dancers, drumming and a heavy police presence, the Olympic torch landed in Rio on Wednesday morning amid signs that many in the city are finally beginning to succumb to the spirit of the games.

The good mood didn't last long.

The day started with smiles and ended with police firing tear gas and rubber bullets at protesters in an outlying town. Along the way, a torch carrier bared his buttocks in a novel protest against Brazil's unpopular interim president, Michel Temer.

The games have been bedeviled by problems — with Rio state declaring itself virtually broke amid rising crime, concerns over a Zika epidemic and complaints over the Athletes’ Village.

On Tuesday, the torch faced protests in three Rio satellite towns, and police used tear gas to disperse demonstrators in tense scenes. In Niteroi, just across the bay from Rio, its route was diverted by almost a mile to avoid one group of protesters, but it ran into another.

The flame's journey around Rio center started well on Wednesday morning. It was sailed across the picturesque Guanabara Bay by past and current Brazilian Olympic sailors and met with samba drumming and dancing when left a Naval School where it landed. The city's mayor Eduardo Paes even danced a few steps before lifting it with a smile.

Dozens of black-clad riot cops formed a protective cordon and a seething throng of photographers and camera operators jostled for a shot as it headed off.

Ruth Alves, 35, was one of the samba performers greeting the torch when it landed. She is also performing in Opening and Closing Ceremonies.

“Protests against the Olympics won’t resolve the problems that we have,” she said. “The organization and the party have all the dignity of a first world event.”

Cheering crowds greeted the torch when it landed at Cinelandia having traveled the short distance on one of the center's new trams.

Camila Neves, 22, beamed as she filmed on her cellphone. “They are very important for our country, our people,” she said of the Olympics. “I will watch them all on TV because I can’t afford to go. It’s very expensive.” Natalie Demoliner, 31, said she had both negative and positive feelings over the Games because she was concerned over security and transport issues. "I am more worried than excited," she said.

Pre-Olympic tension is reported in all host cities, and Rio has been especially negative about these games.

But Brazilians who slammed the 2014 World Cup soon got on board once foreigners started flooding into the country and the party began. Organizers were hoping the same will happen with these Olympics. In Central Rio, the signs were that this process may have begun.

“I want to have a little of the feeling the ancient Greeks had when it passed,” said librarianship student Tatiana Leal, 38, after photographing the torch.

She said she objected to the way Games construction had been handled — especially the demolition of a poor community, or favela, called Vila Autodromo that was beside the Olympic Park. But she also looked forward to mingling with foreigners, which she had enjoyed during the 2014 World Cup.

“It is a little contradictory,” she said.

When the procession reached Praca Maua, a waterside square renovated for the Olympics, more crowds cheered.

The Games "encourage tourism, bring visibility,” said Dânae Mazzini, 32. “They cause stress but that’s part of it.” Sergio Costa, 35, said new transport links mean the Games are a "mark for Brazil."

The torch headed into the Gamboa neighborhood, renowned for live samba in its picturesque colonial squares and a dark history as the area where slaves were docked, sold and buried. A saxophone player played along. Police in their heavy, riot gear jogged to keep up, shouting: “Hup! Hup!” A police officer led the way, cradling an automatic rifle.

The procession passed a hospital. Children jumped in the air and chanted: “Torch! Torch!” Eliza Ramos, 52, stood smiling in the doorway of an old, derelict house. “It is beautiful, a unique moment,” she said.

Her enthusiasm was not shared by Carlos Nogueria, 22, who lives in the building with his partner Nadia Santos, 21, and their two-year-old son João Guilherme.

He said police had flicked him the finger as they passed. “This is the Brazil we live in,” he said.

Then Tarcisio Cisão, a musician from a samba group called Amigos da Onça, took the torch. And just as he was handing it over, he launched his own protest against Brazil's interim President Michel Temer — who took over when President Dilma Rousseff was suspended for an impeachment process. Cisão dropped his trousers to reveal the words "Temer Out" on his buttocks and was bundled away by a municipal guard, while laughing, his modesty protected by a G-string. As musicians played, delighted onlookers chanted: "Temer out! Temer out!" A video of the scene has already been watched 40,000 times.

The jocular mood of that protest soured when the torch reached the low-income, outlying town of Duque de Caixias. Here it was met with another demonstration which riot police responded to with tear gas and rubber bullets. This video captures some of the tension and confusion — and the jeering with which crowds saw off the Olympic convoy. Worryingly for Rio 2016 organizers, it has already been watched more than half a million times.

Renan Farias, 33, the public servant who filmed the police reaction and posted it to the O Caixiense Facebook page he runs, said a few hundred teachers were peacefully protesting late salaries in a city where many residents are angry over failing public services and high crime.

“We were there covering. There were a lot of children. When the torch got close the police started attacking the protesters. Tear gas, rubber bullets, percussion grenades,” he said. “I was scared to get hit by a rubber bullet. I had never seen this in my life.”