Just one night after Mexico beat Panama 2-1 in a controversial Gold Cup semifinals, the two countries' junior sides played to the same final score in the Pan Am Games.
Angel Zaldivar opened the scoring in the second minute for Mexico, heading home off a long cross in from the right flank.
Mexico held the advantage until the 59th minute, when Panama's Josiel Nunez picked up a poor clearance in the box and blasted a shot that deflected off goalkeeper Manuel Lajud's hands and into the side netting.
With the score even at one goal each, Mexico struck right back through Carlos Cisneros in the 61st minute. El Tri's No. 11 was in the right place at the right time to volley home a free kick that had bounced off the Panamanian wall to give his team a 2-1 lead they wouldn't relinquish.
Brazil fell 2-1 to Uruguay after conceding two goals in the final five minutes of the match, including the winner to Michael Santos in the 87th minute.
Both teams finished with 10 players, but it was Uruguay who played the majority of the match down a man after Paolo Lemos was shown a red card for punching a Brazilian player in the 10th minute.
A 75th minute strike from Clayton looked to have Brazil in control, but in the 86th minute Andres Schettino levelled for Uruguay with a cool finish on the back end of a corner kick.
Santos broke free a minute later for the winner past Brazil's Andrey Da Silva to put Uruguay into the final.
Mexico will play Uruguay in the final, while Panama and Brazil will play in the third-place consolation match.