Carlos Beltran hit his 27th homer as the Cardinals, trounced by the Giants 15-0 the previous night. St. Louis has won seven of its last 10.
Wainwright (10-10) allowed one run and five hits, striking out seven and walking three. He has given up two earned runs or fewer in his last five starts.
Jason Motte pitched the ninth for his 25th save in 29 chances.
Beltran, who leads the NL with 80 RBIs, hit a two-run homer off Madison Bumgarner (12-7) in the first inning. Bumgarner has given up 18 home runs - 15 on the road.
Bumgarner gave up three runs and three hits and struck out seven in six innings.
Jon Jay went 2 for 3 and reached base three times for St. Louis, which completed a seven-game homestand with a 5-2 mark.
San Francisco closed to 2-1 in the fifth on a bases-loaded sacrifice fly by Marco Scutaro.
Joaquin Arias and Bumgarner singled with one out before Wainwright walked Angel Pagan. Scutaro, who hit a grand slam and drove in a career-high seven runs Wednesday night, has hit safely in 11 of 13 games since he was acquired from Colorado on July 27. Wainwright then got Melky Cabrera to pop out to end the inning.
St. Louis pushed the lead to 3-1 in the sixth when Jay doubled, stole third and came home on Allen Craig's sacrifice fly.
Giants star Buster Posey extended his hitting streak to 13 games with a single in the sixth.
NOTES: The Giants had scored in the first inning in each of their previous seven road games before Wainwright stopped them. ... San Francisco has scored 93 runs in 13 games since the All-Star break. ... St. Louis INF Daniel Descalso is in an 0-for-13 slump. ... St. Louis opens a three-game series at Philadelphia on Friday. Kyle Lohse (12-2, 2.79 ERA) will face Roy Halladay (5-6, 4.02). ... The Giants begin a three-game set at home against Colorado. Tim Lincecum (6-11, 5.43) takes on Tyler Chatwood (1-2, 6.61).
Link to boxscore: St. Louis 3, San Francisco 1