Ryan Theriot had two hits and drove in a run as the Cubs won for the fifth time in six games and remained 6 1/2 games behind Colorado in the wild card race. Sam Fuld added two hits.
The Cardinals, who lost 2-1 to Colorado, saw their magic number to win the division remain at one.
Tim Lincecum (14-7) lasted seven innings, giving up two runs and seven hits. He walked three and struck out seven for the Giants, who fell five games behind the Rockies and 1 1/2 games behind the Atlanta Braves. Lincecum had one of the Giants' hits.
Zambrano (9-6) struck out nine and walked one in winning his second straight decision and extending his unbeaten streak to five games. It was his fourth career shutout and ninth complete game.
The Giants managed to get one runner as far as third against Zambrano, who retired nine of the first 10 hitters he faced and 17 of the final 18.
Zambrano faced the Giants for the first time since August 2007 and improved to 5-1 against them in nine games, including eight starts.
Kosuke Fukudome doubled to lead off the sixth and scored on Theriot's single.
Zambrano beat out a potential double play ball, which allowed Bobby Scales to score.
Randy Johnson made a rare relief appearance in the ninth for the Giants and allowed a single to Fuld and Zambrano's RBI double.
NOTES: Cubs 1B Derrek Lee missed the game with neck spasms. ... Giants IF Edgar Renteria will undergo surgery to remove bone chips in his right elbow Saturday and will miss the rest of the season. ... Cubs RHP Kevin Gregg missed his fourth game with mild inflammation on the left side of his rib joint.