World Cup hosts Brazil triumphed 2-1 thanks to Lazaro Vinicius Marques' 93rd-minute winner on Sunday at the Bezerrao.
Mexico – winners of the showpiece tournament in 2005 and 2011 – looked on track to add a third title to their collection when Bryan Alonso Gonzalez Olivan headed home the opener in the 66th minute.
But Brazil, playing in front of legends Ronaldo and Cafu, rallied courtesy of Kaio Jorge's questionable penalty with six minutes of regulation time remaining.
Brazil then completed the comeback deep into stoppage time when Lazaro volleyed home a last-gasp winner.
The victory added to Brazil's successes in 1997, 1999 and 2003 as they moved within one of Nigeria's record of five championships.
The Selecao won all eight of their games at the tournament with Kaio Jorge the side's top goal scorer with five strikes to his name.
Mexico meanwhile, who recently won the U-17 Concacaf tournament, drew their opening match against Paraguay before ending the group stages with an emphatic 8-0 win over Solomon Islands.
They then required penalties to dispatch Netherlands in the semi-finals and will be gutted to have let a lead slip so late against Brazil in the decider.
Dutch striker Sontje Hansen ended the World Cup with the golden boot for his six goals, while Selecao star Gabriel Veron was voted the best player of the tournament.
France claimed bronze in Brazil after beating Netherlands 3-1 in their third-place match with Arnaud Kalimuendo-Muinga netting a hat-trick for the victors.
England, who won the U-17 World Cup in 2017, failed to qualify for the tournament after being eliminated in the group stages of the U-17 European Championship earlier this year.
Peru, who last competed in the U-17 World Cup in 2007, are set to host the next tournament in two years time with 24 nations to compete across six cities.
While they now have a record fifth World Cup in their sights, Brazil will be focused on simply qualifying for the tournament with the past two winners failing to do so.