LUSAIL, Qatar (AP) -- Henry Martin and Luis Chaves each scored in Mexico's furious attempt to stay alive at the World Cup, but the 2-1 victory Wednesday night over Saudi Arabia was not enough.
Because of Argentina's 2-0 victory over Poland in a simultaneous match, Mexico failed to advance out of its group for the first time since 1978.
Mexico had reached the knockout round at the last seven World Cups, second only to Brazil, which has gone through to the round of 16 since 1986.
El Tri went into the match at Lusail Stadium needing both a victory and help from Poland playing across town against Argentina to advance in Group C. Argentina's victory meant goal difference came into play.
Martin scored in the 48th minute to give El Tri hope, and the team's chances got even better with Luis Chavez's goal on a free kick four minutes later.
Mexico tried desperately in the final 20 minutes to get another goal -- including an effort by Uriel Antuna in the 87th minute that was ruled offside -- but came up short.
Salem Aldawsari scored in second-half stoppage time for Saudi Arabia, which was eliminated along with Mexico.
Martin's goal ended Mexico's 431-minute scoring drought at the World Cup, dating back to their second group match at the 2018 tournament in Russia. It was the team's longest ever stretch without a goal.
Mexico opened the tournament in Qatar with a 0-0 draw against Poland and but fell 2-0 to Lionel Messi and Argentina.
Mexico hadn't been eliminated from the group stage since the World Cup in Argentina 44 years ago. El Tri didn't qualify for the 1982 World Cup in Spain, and was banned from the 1990 event in Italy for using overage players at an under-20 tournament.
Mexico advanced to the round of 16 in its last seven appearances -- but no further. El Tri came to Qatar looking to play in an elusive "quinto partido" -- a fifth game -- for the first time since Mexico hosted the tournament in 1986.
Saudi Arabia had one of the tournament's biggest ever upsets ever when it beat Argentina 2-1 in its opener. But the Green Falcons couldn't pull off another surprise in its second match, a 2-0 loss to Poland.
The Saudis reached the round of 16 back in 1994, the team's World Cup debut, but haven't made it past the group stage since.
"Tonight it was difficult to breathe with the intensity Mexico put into the match," Saudi Arabia coach Herve Renard said.
Many of the Saudi team were also part of the squad that went to the 2018 World Cup. But none play outside of their home country. Twelve players on the roster are with Al Hilal, which has won a record 18 Saudi league championships.
Mexico dominated the first half. Orbelin Pineda had one of the best of three good chances for El Tri, but it was easily grabbed by Saudi Arabia goalkeeper Mohammed Alowais in the 25th minute.
The game turned quickly in Mexico's favor with Martin's goal, but the celebration was muted. Chavez's free kick in the 52nd that went into the upper corner just out of Alowais' reach brought Mexico's reserves rushing onto the field.
Hirving Lozano nearly had a third goal but he was offside. Chavez had another free kick that missed as Mexico tried in vain to score more goals.
Mexico coach Gerardo "Tata" Martino was roundly criticized for the lack of scoring. He had already been questioned over some of his choices, including his decision to leave all-time leading scorer Javier "Chicharito" Hernandez off the team.
Hernandez, who now plays for the LA Galaxy in Major League Soccer, scored the team's last goal in a 2-1 group-stage victory over South Korea in Russia.