Mexico suffered an agonising exit from the World Cup on goal difference on Wednesday despite beating Saudi Arabia 2-1 in a dramatic finale to Group C.
Second-half goals from Henry Martin and Luis Chavez secured victory for Mexico but they finished third behind Poland after Salem Al-Dawsari's late strike.
Mexico desperately pushed for a third goal in an effort to improve their goal difference as they faced elimination on FIFA fair play rules.
Saudi Arabia's win over Argentina in their opening match was one of the World Cup's great upsets, but they crashed back down to earth with a 2-0 loss to Poland in their second game.
Coach Herve Renard urged his players to show that was no flash in the pan and write themselves into Saudi football history by reaching knockout rounds for the first time since 1994.
Having failed to win either of their first two group games for the first time in 44 years, Mexico knew victory was essential if they were to stand a chance of reaching the last 16 at an eighth successive World Cup.
Mexico boss Gerardo Martino ditched the back five he used in the 2-0 loss to Argentina and brought in Martin to lead the attack.
It almost reaped immediate rewards but Saudi goalkeeper Mohammed Al-Owais raced out to block Alexis Vega after he was slipped in behind the defence by Hirving Lozano.
Al-Owais, one of the heroes of the 2-1 win over Argentina, tentatively palmed away a bouncing cross ahead of a lunging Martin and held weak attempts by Chavez and Orbelin Pineda.
Mohamed Kanno whipped a free-kick just over for Saudi Arabia, who saw defender Ali Al-Bulayhi forced off with injury -- adding to their mounting casualty list.
Mexico continued to attack without success and Ali Al-Hassan nearly sent the bulk of the largely Saudi crowd wild late in the first half with a diving header that flashed wide of the far post.
Chavez tested Al-Owais right after the interval and Martin soon broke the deadlock as he turned in from close range following Cesar Montes' clever flick-on at a corner.
Mexico's second goal arrived just five minutes later when Chavez sensationally curled a free-kick into the top corner from 30 metres.
Keeping an eye on the score between Argentina and Poland, Mexico pushed relentlessly for a third goal, with Lozano's effort ruled out for a tight offside.
Martin blazed over when he had a glorious chance and Chavez had another free-kick turned away by Al-Owais, who also sprawled to his right to claw out a drive from Lozano.
Uriel Antuna then had another goal disallowed for offside before Al-Dawsari's late strike put an end to the drama.