RIO DE JANEIRO — When Mario Götze settled a crossing pass with his chest and volleyed a goal that won the World Cup, German fans roared in ecstatic release. Those from Brazil were nearly as delirious, even if it was out of relief as much as celebration.

It might have seemed an odd sight, Brazilian fans celebrating another team inside their own cathedral of soccer, the Maracanã stadium. But after two demoralizing losses brought national embarrassment, solace finally came Sunday as Germany defeated Argentina, 1-0, to become the first European team to win a World Cup played in North or South America.

“Argentina winning would have been the worst thing I could think of,” said Jaime Costa, 30, a Brazil fan who works in publicity for a music company.

By the tens of thousands, Argentine fans had crossed into neighboring Brazil, many sleeping in tents and mobile homes and taunting their chief rivals by singing, “Brazil, tell me how it feels to have your daddy in the house.” Roughly, that translates as “How does it feel to be bossed around in your own backyard?” Brazil lost, 7-1, to Germany last Tuesday in the semifinal round — its worst defeat ever — and then appeared feeble again in a 3-0 loss to the Netherlands in Saturday’s third-place game. Meanwhile, Argentina had reached the final for the first time in 24 years, led by its star Lionel Messi, widely considered the best player in the world.