Neymar made the difference for Brazil again, scoring in the ninth minute and setting up Jo's injury-time goal to give the hosts a 2-0 win over Mexico and a spot in the semifinals of the Confederations Cup.
The Brazilian striker scored his second goal of the tournament with a left-footed volley from just inside the penalty box after Mexican defenders failed to clear a cross, then slipped past two defenders at once to set up Jo for an easy goal in the final move of the game.
"I'm happy to have played well again," Neymar said. "But what was more important was that the team had a good performance. We are improving game after game and we are getting better. This gives us more confidence for the next matches."
Mexico, which had won two of its last three matches against Brazil, fought strongly but had little finishing power up front. It was eliminated from the World Cup warm-up competition with the loss, the team's second-consecutive. It had fallen 2-1 to Italy in the opener.
Brazil, which opened with a 3-0 win over Japan, will play Italy on Sunday (NZT) to see which team will finish first in Group A. Italy rallied to beat Japan 4-3 to pick up its second win.
One of Brazil's recent losses to Mexico was in the Olympic final last year, when the team led by Neymar and Oscar were considered favorites to win Brazil's first gold medal in football but failed to come out victorious.
"We had been having problems with Mexico recently and that Olympic final was still in the mind of some of our players who were there," Brazil coach Luiz Felipe Scolari said. "It was important to get this victory against them."
Backed by loud home fans packing the Arena Castelao in the northeastern city of Fortaleza, Brazil came out attacking from the beginning and it took a while before Mexico could get into the game. The Brazilian players were constantly getting the crowd involved and had their support throughout the match.
Mexico had few chances but came close to scoring an equaliser late in the second half. The best chance was a shot by Andres Guardado that was deflected by a defender in front of goal.
"We were not able to capitalise on our scoring chances," Mexico coach Jose Manuel De la Torre said. "I don't think this should be considered a failure, because for me failure is when you stop fighting. But our main goal was to advance and we were not able to do that."
Brazil opened the scoring after a run by Barcelona right back Daniel Alves down the right side. His cross to striker Fred inside the area was partially cleared by Mexico captain Francisco Rodriguez and the ball went toward Neymar, who struck a difficult shot on the volley.
With the clock running down and Mexico pressing desperately for an equaliser, Neymar wriggled through two defenders near the touchline and crossed for Jo to score from five yards. Neymar was named man of the match for the second time in a row.
It was Brazil's first match since the players publicly expressed their support to a historic wave of protests that has swept across the South American nation in recent days to demand for better public services to the population.
Neymar, recently signed by Barcelona and Brazil's biggest star, has been criticissed for not being able to replicate his Santos success with the national team, but he has played well in the first two games at the Confederations Cup.
He was the Brazilian player who threatened the most, creating chances and imposing difficulties on the Mexican defence throughout the match.
"Neymar has the skills and he created problems for the players from Mexico the entire match," Scolari said. "He did what we needed him to do to help us break through the Mexican defense."
Neymar almost scored his second goal of the day with a shot that went over the crossbar in the 23rd. In the 56th, he sped past a defender and shot just wide, and in the 66th his low right-footed shot was tipped away by Mexico goalkeeper Jose Corona after a powerful run by midfielder Paulinho.
Daniel Alves nearly added to Brazil's lead in the 14th with a remarkable lob shot that forced Corona to make a difficult save with the tip of his gloves. Oscar had a goal disallowed just five minutes into the match because Neymar was caught offside before making crossin for the Chelsea playmaker. Captain Thiago Silva also had a goal called off for offside in the 47th.
Hulk had his chance after a pass by Neymar in the 55th, but his shot from close range struck the side of the net.
Mexico's only significant chance in the first half came with a low cross shot by Hiram Mier that just missed the target in the 16th.
Will Burnley retain their EPL status?