Wainwright (7-8) struck out seven and walked one.
The Cardinals had a 2-1 lead when Wainwright left the game, but David Freese singled in two insurance runs in the eighth.
John Jay had an RBI double in the first for the Cardinals and he drove in another run in the second when he was hit by a pitch with the bases loaded.
The hit batsman cost Jeremy Guthrie (3-8) the loss. He allowed just two runs on six hits in six innings.
Jason Motte gave up a pair of two-out singles in the ninth, but then struck out Dexter Fowler to end the game and earn his 18th save.
Members of Congress to keep receiving porn magazine
Rosie O'Donnell unveils nearly 50-pound weight loss