Jonathan Niese (3-4) allowed two runs on six hits in 7 1/3 innings, his longest outing of the season. He ended his four-game losing streak over five starts since a win at Minnesota on April 12.
The Mets avoided a four-game sweep by getting to the Cardinals ace. Wainwright (5-3) was coming off a two-hit shutout in which he no-hit the Rockies for 7 1/3 innings.
Murphy went 4 for 4, doubled twice and walked, and was 9 for 15 in the series. Wright doubled, singled and drove in two runs.
The Cardinals have never swept the Mets in a four-game series at home, almost always playing three-game sets.
Wainwright faltered after allowing one hit with four strikeouts the first time through the order. He allowed three earned runs in six innings, and is 1-4 with a 7.29 ERA against the Mets for his career.
Niese had permitted 15 runs in 8 1/3 innings in his previous two starts, but kept the Cardinals off-balance.
Niese is 3-1 in five starts against the Cardinals. He had three strikeouts and two walks to make him even on the year with 24 strikeouts and walks.
Bobby Parnell finished for his fourth save in six chances.
Newly signed Mets center fielder Rick Ankiel appeared to get a late jump on Kozma's apparent routine fly ball and couldn't make a diving catch for an RBI double that put the Cardinals in front in the second.
Jordany Valdespin beat out a bunt with two outs in the Mets' third and scored on a headfirst slide on Murphy's double. Wright's single put the Mets ahead.
Murphy and Wright doubled to start the sixth to give Niese a two-run cushion. Wright later scored on Lucas Duda's sacrifice fly.
Ankiel was credited with a ground-rule double leading off the seventh on a ball down the third-base line that appeared to glance off an usher's leg before hitting a railing. He was thrown out at second off the carom, and replays showed the usher barely made it out of the way.
Notes: Mets 1B Ike Davis struck out four times and was 0 for 5. ... 1B umpire Tim Timmons missed a half-inning early in the game, returning before the bottom of the fourth. No reason was given for the absence. ... Since 2000, the Mets are 16-31 against the Cardinals in St. Louis. ... Mets starters had been 1-7 with a 5.72 ERA the previous 13 games. ... Seth Maness, who got the win Wednesday after allowing Ankiel's tying two-run homer in the seventh, is the Cardinals' only player since 1900 to earn three victories in relief in his first five career appearances. Jason Simontacchi won his first three relief appearances in 2003 after beginning his career in the rotation.
Link to box score: New York 5 at St. Louis 2
Link to game discussion at The Cardinal Nation message board