As the sound of helicopters and the tang of teargas filled the air on the first day of a World Cup that had proved more divisive among its own people than any other, initial signs in Brazil were not promising. Inside the security cordon at the barely finished Arena Corinthians, President Dilma Rousseff had promised a “Copa das Copas” – the Cup of Cups.

She left with obscene chants ringing in her ears as the national team needed the help of the referee to deliver an unconvincing victory. But four weeks on, it is hard to argue Brazil has not delivered, even if Luiz Felipe Scolari’s emotional side ultimately came off the rails in spectacular fashion.

By the eve of the final the atmosphere was very different. Tens of thousands of Argentinians mingled with Brazilians and international fans on Copacabana, drinking, dancing and singing. Families in Brazil shirts waved Germany flags and makeshift bars sold endless beers and caipirinhas.

“We showed that our people know how to have good interaction not only among ourselves but with the foreigners that we received,” said Rousseff on the eve of the final. “We competently maintained peace and order, as well as having good airport administration, among other successes.”

Rousseff, desperate for a successful tournament to boost her re-election chances in October, added: “We’ve eliminated the doubts of all who didn’t believe in us.”

She was right: Brazil was an intoxicating and welcoming but not unquestioning host, providing the platform for a soul-stirring football feast. Fears of transport chaos and operational dysfunction were unfounded.

But she was also wrong: the argument over whether $13.5bn of public money invested in the tournament was well spent in a country with many other pressing needs will continue long after the Fifa circus has left town. That is particularly the case in places such as the Amazonian jungle destination of Manaus or the coastal city of Natal where new stadiums have no obvious sustainable use.

Across the vast country, road, rail and infrastructure projects that formed part of the rationale for holding the tournament in the first place lie unfinished.

How and why a tournament that was seven years in the planning was delivered with indecent haste is worthy of further debate, as are the evictions in host cities that displaced families in the name of progress. The collapse of an overpass in Belo Horizonte, killing two people, was a reminder of the human cost of a last-minute construction dash that also cost the lives of eight workers battling to get the stadiums finished in time.

But judged on its own terms, Brazil delivered. The stadiums were finished and full. As is so often the case with increasingly overblown “mega events”, the unpaid volunteers recruited to deal with the public smoothed over many cracks.

Fans actually revelled in some of the rough edges. The ongoing attempt to ensure a cookie-cutter experience for sponsors and hospitality guests has robbed the World Cup of its charm over decades.

But probably scared of a possible backlash, the branding from sponsors felt less overt here and the policing of Fifa’s “rights” less draconian than at previous tournaments. For many, the so-called “fan fests” remain airless experiences.

But the millions packing them under sunny skies in often stunning locations did not seem to care. And at least they offered those unable to afford the often eye-watering ticket prices an opportunity to grab their slice of the (heavily sponsored) World Cup experience.

For the sponsors bounced into registering their concern over the corruption allegations washing over Fifa before the World Cup, it was largely business as usual.

And as is always the case with World Cups, particularly those blessed with a country with as many natural advantages as Brazil, it was the people who made the atmosphere and the football that dictated the mood.

Argentinian camper vans parked up along Copacabana, Chilean chants filled the night sky in São Paulo, Mexicans flooded into Fortaleza and Costa Ricans set up camp in Salvador.

Rio was the melting pot for fans from around the world. If Germany in 2006 felt like a good-natured, beer-drenched gathering of the European clans then Brazil was its equivalent for South and Central America.

The night that Colombia beat Uruguay and Brazil squeezed past Chile the streets of Rio became a huge impromptu party. In the northern coastal cities of Fortaleza and Salvador, there was an abandon sometimes absent in the vast megalopolis of São Paulo.

Huge tribes of American “Outlaws”, Colombians, Costa Ricans, Uruguayans, Mexicans and – most visibly – Argentinians slept on the beaches, on benches, in hostels and upmarket hotels. They all went away with a better understanding of the country and it of them. Whatever their underlying reservations about Fifa and their government, Brazilians welcomed them all with open arms.

While stadiums were full, the occupants of the seats excited much debate. The Brazilians filling the seats were almost exclusively white and well off. A poll taken at Brazil’s narrow victory over Chile by the Folha de S Paulo newspaper found that 67% of fans were white in a country where more than half the population describe themselves as black or mixed race. Nine out of 10 came from Brazil’s top economic classes.

That is a pattern repeated at every major sporting event around the world. But if Fifa is to make a virtue of taking its flagship event to new, fast-developing markets that have huge disparities between rich and poor, surely it is duty-bound to find better ways of allowing more people to experience the event they are ultimately paying for?

Underpinning it all was an organising committee and a government desperate to pull off the first of two “mega events” in the space of two years and paddling furiously beneath the water. Holding a World Cup and an Olympics back to back is unprecedented. Attempting to do so in a country like Brazil, with its three layers of government and endemic corruption issues and social problems, is bound to create tension.

This vast, complex, engaging country is well capable of separating arguments about public-spending priorities from its attachment to the Seleção and the welcome it affords overseas visitors.

The Fifa president, Sepp Blatter, wisely kept his head down throughout and desperately hoped the dogged police investigation into a $100m ticket-touting ring would not spiral into a major embarrassment.

It can sometimes feel like there are two Fifas. One was on show the week before the tournament, when the discredited and dysfunctional executive committee sat onstage at Fifa’s Congress as corruption claims besieged the walls of a São Paulo conference centre. The other is the army of highly efficient staff who make sure the tournament runs smoothly. The way they keep things running on the ground and package the World Cup for global consumption is impressive.

But it also creates its own problems. Fifa has perfected the art of swooping in and creating a slick, temporary bubble in which the World Cup takes place. But it then gathers up its $4bn in revenues from each World Cup cycle and moves on. The host country is left counting up its white-elephant stadiums and counting the cost of the event.

The mass protests that occurred during the Confederations Cup were not repeated. That was partly because the wider population put their concerns aside and resolved to enjoy the party.

But it was also because public areas were flooded with police and the military and because a range of worrying tactics were used to suppress protest.

Human rights groups registered concern that protest organisers and lawyers had been arrested and intimidated, while those who did manage to protest often found themselves facing heavy-handed policing involving the use of rubber bullets and teargas.

Public feelings towards the World Cup were bound up in underlying concerns about government corruption, the level of investment in public services and the quality of healthcare and education.

But they were also bound up in distaste, fermented over many years, not only for Fifa but for the men who run the sport in Brazil. The hope is that defeat to Germany will act as a long-overdue catalyst for change.

It is not too melodramatic to say that the action on the pitch has rescued the World Cup as we know it, and perhaps even international football itself.

But Fifa and the Brazilian authorities should not be allowed to get away with using it to whitewash their deeper issues. This World Cup’s greatest legacy might be a wider movement behind the message scrawled on walls throughout Brazil: love football, hate Fifa. And, by extension, much of the corporate machinery that surrounds modern football.

Paradoxically, given the big business around it and the political questions that framed it, this felt like a World Cup that brought home football’s ability to unite and to provide moments of unexpected, unalloyed joy. For that, Brazil deserves eternal thanks.