Lincecum (6-1) labored through six innings, allowing three runs as he fought his control.
"In my eyes, this was one of my worst outings ever," Lincecum said. "I battled, but I never want to go through that again."
Wilson knows the feeling. He picked up his NL-tying 13th save of the season, but it was far from pretty. With the Giants up 6-3 heading into the ninth, he gave up a two-run, two-out homer to Clint Barmes and watched as Matt Holliday's double banged off the top of the right-field wall, before eventually striking out Garrett Atkins on a 96-mph fastball.
Not exactly the way Wilson envisioned things going, but somewhat typical of the way his season has gone. His ERA is 5.79.
"I didn't want to blow Timmy's win," Wilson said. "You don't want to let the team down after a hard day's work."
The Giants couldn't have asked for a better pitcher on the hill to curtail their losing streak. Lincecum improved to 4-0 this season when pitching after a San Francisco loss.
But he was far from pleased, especially after walking four and throwing 113 pitches.
"I didn't have any rhythm," said Lincecum, who entered the game with the NL's best road ERA (0.39). "I was struggling out there."
Although it was a little nerve-racking watching the Rockies come back in the ninth, Lincecum had faith in his closer.
"He held it in there," he said. "He didn't show any emotion on the field, just buckled down and made pitches when he needed to."
Randy Winn extended his hitting streak to 15 games, the longest current streak in the majors, with a double in the first and Rich Aurilia had a big night at the plate as well, going 3-for-4 with a solo homer in the second.
Barmes extended his hitting streak to 13 games with his fifth homer of the season, but the Rockies had their three-game winning streak snapped.
"There were opportunities again out there throughout the game from the offensive side," Rockies manager Clint Hurdle said. "Hopefully, we'll get some guys finding their way offensively."
After winning six straight decisions, Aaron Cook (6-3) has fallen on hard times, dropping two in a row. He lasted seven innings, giving up 10 hits for a second straight game.
"For this outing, I didn't really give us a chance to win the game," said Cook, who helped his cause with an RBI single in the second.
Bengie Molina finished 3-for-4 with an RBI double in the first that was originally ruled a home run before he was placed back at second after the umpires discussed the call. Replays showed that Molina's shot off the wall in left-center may have smacked off the hand of a fan above the yellow home run line, causing the ball to ricochet back onto the field.
The Giants still scored as Aaron Rowand's bloop single to left brought in Molina, staking the team to an early 2-0 lead. Rowand finished the night 2-for-5 with two RBIs.
For San Francisco's Bruce Bochy, the win had added significance as he picked up managerial win No. 1,040, tying him with Steve O'Neill at No. 50 on the all-time list.
And it was only fitting the game was decided by a run since the 21 of the Giants' last 47 games have been by that margin, tops in the majors.
Bochy would've preferred a nice easy 1-2-3 ninth instead of all the drama.
"Willy [Wilson] has a way to keep you on the edge of your seat," Bochy said with a grin.
Omar Vizquel played his 2,580th contest at shortstop Tuesday, moving him three away from tying fellow Venezuelan Luis Aparicio for the all-time lead in games played a the position. ... Vizquel drove in a run with a squeeze bunt in the fourth. ... 2B Omar Quintanilla went 2-for-4 with two runs scored. ... Rockies shortstop Tulowitzki took on-field batting practice Tuesday for the first time since suffering a torn quadriceps muscle on April 29. ... Fred Lewis hit his fourth homer of the season, a solo shot in the eighth.