"It was nice," said Carpenter, who allowed a run in 7 1/3 innings. "We just need to win some ballgames. Going against a guy like Lincecum, you know it's going to be a tough night. It was nice to see our guys go out and get some runs and enable us to win."
Newcomer Pedro Feliz also helped hand Lincecum the first four-game skid of his career. Feliz had two hits and two RBIs, giving him four hits in two games with St. Louis since coming over in a trade with Houston Thursday.
"You don't play regularly on a championship team like he did for Philadelphia unless you can do everything," Cardinals manager Tony La Russa said of his new third baseman. "He's a quality veteran. We're glad we got him."
Lincecum (11-8) began the day 5-0 with a 1.54 ERA in five starts against the Cardinals. But the defending two-time NL Cy Young winner was tagged for four runs on six hits and two walks in 5 1/3 innings.
In his last four starts, Lincecum has allowed 28 hits and 18 runs in 19 1/3 innings. Lincecum, however, said he felt more like his usual self Saturday.
"In my mind, I feel like I'm getting back to form," Lincecum said. "For the most part, I felt I was aggressive. I just got bit a couple of times."
Carpenter has been going in the opposite direction of Lincecum. He gave up five hits, walked two and struck out four.
"He was tough," Giants manager Bruce Bochy said of Carpenter. "Real pitchers at the top of their game, they're always tough."
Top pitchers generally get better as the game progresses, and that was the case with Carpenter.
"As the game went on, I felt I like I got stronger," Carpenter said. "I felt like was able to locate well with all my pitches and get outs."
Added La Russa: "Everything we had going down, the losing streak, going against Lincecum. He really gave us the lift we needed."
A trio of pitchers combined on scoreless relief.
Randy Winn, making a rare start, hit a solo home run for the Cardinals.
Buster Posey had two hits for the second straight night for the Giants. He is hitting .401 on the road this season.
Lincecum was cruising until Winn led off the fourth inning with a 419-foot homer to right field for the first run of the game. The homer was only the Cardinals' second ever off Lincecum. Skip Schumaker took him deep on July 7, 2007.
The Cardinals scored two more runs before Lincecum recorded an out in the fifth. Yadier Molina drew a leadoff walk, Feliz followed with a triple down the left-field line and Brendan Ryan hit a double into the left-field corner to make it 3-0.
Feliz got that run back with an RBI single in the bottom of the inning.
The Cardinals batted the pitcher in the ninth spot for the first time since Carpenter hit ninth on June 13 at Arizona. ... St. Louis is now 49-27 in games started by Carpenter, Adam Wainright and Jaime Garcia. ... Matt Holliday and Albert Pujols both stole bases, giving opponents 23 steals in 26 attempts against Lincecum this season. ... Winn's home run broke a 1-for-19 slump.