The teams were level at 3-3 as the match headed into injury-time but Mexico went ahead in the first added minute through an own goal from Kenwyne Jones.
However, Yohance Marshall spared the striker’s blushes when he headed home a last-gasp equaliser from Joevin Jones’ corner.
The draw enabled Trinidad and Tobago to top the group on seven points, setting up a quarter-final against Panama in East Rutherford, New Jersey on Sunday.
Mexico, Gold Cup champions in 2009 and 2011, finished on five points and advanced to take on Costa Rica in the second game at the same venue on Sunday.
The Mexicans started well and led 2-0 after 51 minutes when Paul Aguilar and Carlos Vela scored either side of half-time before Trinidad and Tobago rallied to take the lead with Keron Cummings netting twice (54 and 66) and Kenwyne Jones once (57) in a 12-minute spell.
Mexico then drew level with an Andres Guardado blast with two minutes of normal time remaining to spark off the dramatic finale.
In the early kick-off, Maikel Reyes scored the only goal of the game in the 73rd minute to lead Cuba past Guatemala and into the quarter-finals as one of the two best third-placed finishers at the 12-team tournament.
Reyes, who missed Cuba’s first match due to visa issues, headed home his side’s first goal of the tournament to set up a last- eight encounter against hosts and defending champions the United States in Baltimore, Maryland on Saturday.
Haiti will then take on Jamaica at the same venue in the other quarter-final.