Wainwright (10-3) allowed four hits over seven innings and didn't allow a run. He walked two and struck out six.
The Mets got on the scoreboard in the ninth when Marion Byrd hit his 10th home run of the season. John Buck then doubled and pinch-runner Collin Cowgill reached third with the potential tying run before Edward Mujica struck out Josh Satin to end the game and get his 19th save.
New York starter Matt Harvey (5-1) also pitched well, giving up five hits and one run in seven innings. He walked one and had seven strike outs.
He retired the first seven Cardinals he faced before Pete Kozma singled. Wainwright sacrificed Kozma to third and Matt Carpenter tripled to get the first run home.