Pitcher Giovanny Gallegos celebrates as Mexico clinch victory over Puerto Rico to reach the semi-finals of the World Baseball Classic

Miami (AFP) - Mexico staged a dramatic comeback to stun Puerto Rico 5-4 on Friday and set up a semifinal showdown with Japan at the World Baseball Classic.

In-form Puerto Rico stormed into a 4-0 lead in the first inning after tormenting Mexico’s starting pitcher Julio Urias with some ruthless hitting at Miami’s LoanDepot Park.

Emmanuel Rivera’s sacrifice fly scored Enrique Hernandez to put Puerto Rico 1-0 ahead before Javy Baez and Eddie Rosario launched back-to-back two-out homers to stretch the lead to 4-0.

But Urias settled down to quell the Puerto Rico bats thereafter and Mexico chipped away at the deficit before finally edging ahead in the bottom of the seventh.

Isaac Paredes crushed a home run to center field in the bottom of the second inning to get Mexico’s first score on the board before Alex Verdugo singled in the bottom of the fifth to score Alek Thomas.

Paredes then came up big again in the seventh with a bases-loaded single to left field off Jorge Lopez to score Austin Barnes and Randy Arozarena and make it 4-4.

The Milwaukee Brewers’ Luis Urias then piled on the agony for Lopez with a line drive to right field that allowed Verdugo to scamper home for a 5-4 lead.

Puerto Rico were then denied a game-tying score in the eighth inning after a superb running catch at the wall by Tampa Bay Rays star Arozarena denied Emmanuel Rivera.

Puerto Rico went tantalizingly close to tying again in the eighth but Mexico’s bullpen held firm to end the inning with Puerto Rico runners stranded on first and third.

St. Louis Cardinals reliever Giovanny Gallegos then closed out the ninth, stranding Francisco Lindor and Johneshwy Fargas on base when he struck out Hernandez.

The victory sees Mexico advance to the last four of the classic for the first time in history, where they will face dominant Japan on Monday.