Mexico missed out on reaching the last 16 of the World Cup despite beating Saudi Arabia 2-1.
El Tri started the final round of Group C fixtures in bottom spot but came so close to hurdling into the top two after second-half goals from Henry Martin and Luis Chavez, the latter scoring with a spectacular 25-yard free-kick.
With Poland en route to a 2-0 defeat to Argentina, Mexico knew unless they scored again they would be heading out of the competition because the Poles had collected fewer yellow cards with all other tie-breakers equal between the two nations.
But Mexican hopes were destroyed in the fifth minute of stoppage time when Saudi skipper Salem Al Dawsari worked a clever one-two with Hatan Bahbri and skilfully converted.
Mexico had last suffered group-stage elimination in 1978, having reached the knockout phase in each of their previous seven World Cups.
The sides filled the bottom two spots at kick-off but still with plenty to play for as far as qualification for the last 16 was concerned.
Mexico boss Gerardo Martino left Wolves striker Raul Jimenez on the bench for the third time at this tournament as captain Andres Guardado missed out with a muscle injury.
Saudi Arabia named eight of the starting line-up who had beaten Argentina in their opening game for one of the great World Cup shocks, with injured skipper Salman Al Faraj a notable absentee.
There was huge support for Saudi Arabia inside the Lusail Stadium, venue for the World Cup final on December 18.
Napoli’s Hirving Lozano was at the heart of everything Mexico produced as they got on the front foot from the start.
Chavez had already driven wide before Lozano put Alexis Vega clean through after three minutes, but Mohammed Al Owais sprang from his goal to make an excellent stop.
Mohamed Kanno had two attempts for Saudi Arabia, slashing wide and sending a free-kick just over, but it was Mexico who poured forward at every opportunity.
Chavez volleyed straight at Al Owais, Jesus Gallardo met a corner without success, and Orbelin Pineda saw deflections take the sting out of two attempts.
English referee Michael Oliver had his work cut out to keep the players in check with the sense that tempers could boil over at any time.
Every Saudi block and clearance was cheered as if it was a goal, and the decibel levels were deafening when Ali Al Hassan’s diving header on the stroke of half-time drifted wide of an upright.
The busy Al Owais pushed out a Chavez shot at the start of the second half, but Mexico broke the deadlock from the resulting corner.
Chavez’s kick was flicked on by Cesar Montes and Martin reacted quickest to prod home from close range.
Mexico doubled their lead five minutes later after Hassan Al Tambakti brought down Martin and Chavez sent a spectacular curling free-kick past Al Owais from 25 yards.
Lozano soon had the ball in the net again but this time it was ruled out for offside.
The siege on the Saudi goal was relentless with Al Owais pushing away another superb Chavez free-kick and substitute Uriel Antuna finding the net only to be denied by an offside flag.
It looked as if Mexico had to score, but in the end it was Saudi Arabia who had the final word.