Cardinals pitcher Trevor Rosenthal was late covering first base on a grounder by Jose Reyes that turned into a game-winning single with two outs in the ninth inning, lifting the New York Mets over St. Louis 3-2.
A leadoff walk and T.J. Rivera's single put runners on the corners with two outs. Reyes then hit a grounder up the first base line, and Matt Carpenter fielded it cleanly well behind the bag.
Rosenthal (2-4) was slow to leave the mound, and Reyes easily beat him to the base with a headfirst dive.
Reyes' fourth career walkoff RBI gave the Mets a split of the four-game series.
Addison Reed (1-2) pitched a perfect ninth.
Tommy Pham drove reliever Erik Goeddel's 3-1 changeup into the lower deck in left field to give the Cardinals a 2-1 advantage in the eighth. It was Pham's 13th home run of the season and third against the Mets.
Pinch-hitter Wilmer Flores homered in the bottom half off Brett Cecil to tie it.
Seth Lugo tossed 6 2/3 innings of one-run ball behind a career-high 103 pitches.
Lugo did not allow a hit until two outs in the fifth, when Greg Garcia lined a double into the right field corner.
Lance Lynn allowed one run on three hits in six innings.
Lucas Duda homered into the Cardinals' bullpen to lead off the second, giving the Mets a 1-0 lead and snapping Lynn's scoreless streak at a career-high 14 1/3 innings.
After Carpenter worked a one-out walk in the sixth, Pham hit an RBI double.
St. Louis will open a three-game set at Wrigley Field on Friday afternoon against the Chicago Cubs. RHP Carlos Martinez (6-8, 3.36 ERA) faces RHP Jake Arrieta (9-7, 4.17 ERA) in the series opener. The Cardinals have lost Martinez's last five outings, despite three of them being quality starts.