Updated

Tim Lincecum made up for his shaky first start.

He pitched three hitless innings for San Francisco in his second spring training outing start before Aramis Ramirez hit a tiebreaking, two-run double in a three-run sixth that led the Chicago Cubs over the Giants 3-2 Tuesday.

Lincecum struck out two and allowed only one runner to reach: Starlin Castro on an error by shortstop Miguel Tejada.

"My location was better and I was mixing my pitches back in and out," Lincecum said. "I didn't throw too many off-speed pitches. My rhythm felt quick the first two innings, and then I was able to calm it down in the third."

Lincecum gave up three runs and five hits in 1 2-3 innings in his first start, against Arizona.

He's looking forward to having a full spring to work with catcher Buster Posey after veteran Bengie Molina yielded to Posey last year.

"Since he came up in the middle of last season all the way until now, I have felt comfortable with him," Lincecum said. "I feel as comfortable with him now as I was with Bengie."

Cubs starter Ryan Dempster gave up one run, two hits and a walk in three innings, striking out three.

Pablo Sandoval had a second-inning, opposite-field RBI double to left, then doubled off the batter's eye 430 feet away in center in the fourth. Sandoval has five RBIs and eight hits thus far, including two doubles and two home runs.

Chicago won for the first time in three spring training games this year.

Cubs right-hander Ryan Dempster started and gave up a run on two hits, walked one and struck out three in three innings. Chicago Right-hander Todd Wellemeyer, the Giants' fifth starter a year ago and now is in his second tour of duty with the Cubs, gave up one hit in two innings and struck out two and got the win.

The Giants got within a run in the eighth on a single by Thomas Neal, and had a chance to tie it in the ninth before Esmalin Caridad got the save.

With two outs and the tying run at third, Brandon Belt pulled a line drive that right fielder Jim Adduci caught at the last moment with the sun in his eyes.

NOTES: Giants CF Andres Torres missed his second straight game with a strained muscle on his left side. Time for his return is uncertain ... Sandoval is now 6 for 13 with two home runs, two doubles and five RBIs. ... Cubs CF Marlon Byrd had two hits and an RBI and is 4 for 6 to start the spring ... Cubs RHP Carlos Silva makes his first spring start on Wednesday against the Milwaukee Brewers.