Brazil's players wept with joy inside the stadium, and Brazilian protesters were sprayed with tear gas outside it as the country's national football team reached the Confederations Cup final despite another wave of mass demonstrations on the streets.
Brazil beat neighbours Uruguay 2-1 with an 86th minute header from Paulinho in a performance that failed to reach the commanding heights of earlier games.
As thousands of anti-government protesters clashed with police nearby, inside the Mineirao Stadiujm, Brazil's footballers reached Sunday's final in Rio de Janeiro with a patchy display.
Security was high at the semifinal as protesters, in part angered by the billions of dollars spent on World Cup preparations, targeted this high-profile semifinal in the latest in a series of demonstrations that have taken place in Brazil during the Confederations Cup. They were met by tear gas and rubber bullets during clashes with police, but the match itself was unaffected by the protests.
'We are not ready yet. We have to go through this, through all these situations so we can grow and evolve... and reach the World Cup in better shape.' — Brazil coach Luiz Felipe Scolari
Protests have already been announced for Sunday's final at the Maracana Stadium.
"It's a new team and this is going to help us grow for the World Cup," Brazil goalkeeper Julio Cesar said. "We know that we can face a very difficult opponent (and win)."
Cesar prevented Uruguay from taking the lead in Belo Horizonte, saving a penalty kick from Uruguay striker Diego Forlan in the 13th minute. The save turned out to be decisive.
Just as they later did for the winner, Paulinho and Neymar combined to help set up Brazil's opener just before halftime.
Fred scores first
Neymar brought down Paulinho's high ball and, after his initial shot was saved by goalkeeper Fernando Muslera, Fred pounced on the loose ball to score.
Although Edinson Cavani seized on sloppy defending to equalize for Uruguay three minutes into the second half, Brazil finally started to click as an attacking force and now either Spain or Italy stand between the host nation and a third consecutive Confederations Cup title.
"We are not ready yet," Brazil coach Luiz Felipe Scolari said. "We have to go through this, through all these situations so we can grow and evolve ... and reach the World Cup in better shape."
"What I have to show them is the progress that they made. This is how I make them self-confident," he said.
With each victory, Scolari is raising expectations that Brazil can replicate its 2002 World Cup success under him and clinch the title for the sixth time in 2014.
"We played with our hearts," Scolari said, before sounding a note of caution: "Mainly, from the middle of the field onwards, we still lack a link there so we can have better chances to score."
Inside the stadium, animosity was directed from the start at Uruguay captain Diego Lugano, who enraged Brazil by accusing Neymar of diving on the eve of the match.
The crowd was even more incensed when Lugano won a penalty in the 13th minute, although there was little to dispute David Luiz's tugging of the defender's shirt.
Facing a wall of noise, Forlan struck low and Cesar dived correctly to his left.
It was the fourth penalty out of eight in the tournament so far to be missed.
Forlan was the most potent attacking threat on the pitch as Brazil struggled to impose itself on the game. The swagger and verve the Brazilians had rediscovered to open the tournament with three group-stage victories was missing in an edgy start by the hosts.
Neymar, on whose shoulders the nation's World Cup hopes are resting, was lacking the service to make an impact.
There was the occasional moment of menace, with Hulk using his strength to burst through the defence, but Uruguay came closer to taking the lead.
Uruguay's resistance was eventually broken by Fred. Two defenders proved to be an ineffective barrier, even to a scuffed shot from Fred which landed in the bottom corner of the net.
Brazil's elation disappeared three minutes into the second half.
Slack defending gifted Uruguay its way back as several chances to clear the danger were wasted. A clearance from Luiz lacked urgency, then Thiago Silva's pass to Marcelo was easily intercepted by Cavani, who scored past Cesar.
However shoddy the work of Brazil's defenders, the quality of the forwards started to shine through as the game became feisty, with five yellow cards awarded.
Brazil pressed and probed for the winner: Fred struck over from Neymar's cross and the star forward had an effort saved himself.
The game was heating up, and Neymar exchanged taunts with Uruguay's Alvaro Gonzalez before sarcastically blowing him a kiss.
But Neymar helped to ensure Brazil had the last say in the match, as he floated a corner into the penalty area that Paulinho rose above Martin Caceres to meet and head into the net.
"It was an even match, maybe we even had more chances than Brazil, but football is like this," Uruguay striker Luis Suarez said. "In the end they found a way to win."