A two-run single by Anthony Rizzo gave the Cubs a 5-2 lead in the fourth and Chicago was still in front by two heading into the ninth.
Kevin Gregg came on to protect the lead and eventually picked up his 12th save in dramatic fashion.
Weeks moved to third on a sacrifice by Logan Schafer and Yuniesky Betancourt hit a grounder to Valbuena at third. Weeks tried to score on the play but was thrown out at the plate.
Gregg retired pinch-hitter Scooter Gennett on a fly ball to right for the final out of the game.
Scott Feldman (7-6) gave up three runs on six hits in six innings to collect the victory. The loss was charged to Yovani Gallardo (6-7), who surrendered five runs on eight hits with four walks in four innings.
Beautician charged with giving client fatal silicone butt injection
McPhee, Cokas 'working on their marriage' after affair