MIAMI -- Luis Urias hit the go-ahead single in a three-run seventh inning that fueled Mexico's 5-4 comeback victory over Puerto Rico to advance to its first-ever World Baseball Classic semifinals.
Mexico will face Shohei Ohtani and Japan in the semifinals Monday. Puerto Rico failed to make it past the second round for the first time.
Isaac Paredes, who homered earlier, tied it at 4 with a single off losing pitcher Alexis Diaz that drove in Austin Barnes and Tampa Bay Rays outfielder Randy Arozarena.
Puerto Rico tried to rally in the ninth with singles from Christian Vazquez and Francisco Lindor, but reliever Giovanny Gallegos got out of the jam for the save.
Arozarena saved the potential tying run in the eighth when he made a leaping catch at the wall in left center.
Puerto Rico was coming off an emotional quarterfinals-clinching victory over the Dominican Republic on Wednesday, when New York Mets star closer Edwin Diaz tore the patellar tendon in his right knee while celebrating the win. The sellout crowd of 35,817 at loanDepot park in Miami cheered when Diaz's jersey appeared on the Jumbotron.
Javier Baez and Eddie Rosario homered off Mexico starter Julio Urias in a four-run first inning.
Rosario hit his second home run of the tournament. Baez, in one of his best games of the event, had three hits, giving him seven total.
Urias allowed five hits and four runs and struck out four before he was lifted after the fourth inning at 60 pitches, which is 20 fewer than the WBC quarterfinals pitch limit of 80.
JoJo Romero got the win.
Paredes made it 4-1 in the second when he homered against Marcus Stroman, which was one of Mexico's five hits off Puerto Rico's starter.
Stroman allowed three singles in the fifth, one of which drove in a run for Mexico to make it 4-2. He had two strikeouts in 4 1-3 innings.
Puerto Rico finished second in the past two WBCs. Earlier in this tournament, its pitchers turned in an all-time performance against Israel in pool play with an eight-inning perfect game.
Mexico won group C with a 3-1 record in pool play.