Seth Maness (1-2) tossed a scoreless 12th for the win. Both teams used seven pitchers.
Trailing 3-2 going into the ninth, Chicago rallied to tie it off closer Trevor Rosenthal on Emilio Bonifacio's RBI single with two outs. The blown save was the first for Rosenthal in 11 opportunities.
The Cardinals took a 3-2 lead in the sixth after Peter Bourjos led off with a bunt single off Carlos Villanueva. Bourjos went to second on a grounder, stole third on ball four pitch to pinch-hitter Jon Jay and scored on Carpenter's grounder. Peralta added an RBI single.
Cubs starter Jake Arrieta went four innings, allowing one run on four hits and five walks. But he helped himself when he led off the third with a single and scored on Valbuena's homer.
St. Louis got one of those runs back in the bottom of the third on a two-out, RBI infield single by Matt Adams.
NOTES: The Cubs are 3-15 in games decided by two runs or less. ... Carpenter went 0 for 5 and is hitless in his last 13 at-bats. . . . Pat Neshek made his team-high 20th appearance for the Cardinals, and pitched a scoreless 11th inning to extend his scoreless streak to 13 1-3 innings. ... The Cubs' Jason Hammel (4-1) opposes Michael Wacha (2-3) on Wednesday.