Hendricks (1-2) faced one batter over the minimum, walking Michael Conforto with one out in the second, and had retired 19 batters in a row before Haniger hit a fastball 378 feet off the left-field wall on the eighth pitch of the at-bat. That ended the longest no-hit bid in the major leagues this season.
Blake Sabol flied out on Hendricks' next pitch.
Julian Merryweather retired three straight batters in the ninth, completing the one-hitter and giving the Cubs consecutive wins for the first time since May 29 and 30.
Christopher Morel homered and drove in three runs and Matt Mervis also homered.
Hendricks started the season on the injured list with a strained right shoulder. He made his season debut May 25 and was making his fourth start. He threw 61 of 94 pitches for strikes, none over 89.4 mph.
The 33-year-old right-hander, in the 10th season of a big league career spent entirely with the Cubs, has six complete games and four shutouts in 226 starts.
Center fielder Mike Tauchman helped by making a diving, backhand catch to rob Brandon Crawford of an extra-base hit near the warning track in the third.
Morel homered off Jakob Junis (3-3) leading off the third. The ball bounced off the top of the brick wall and back onto the field. Unaware of the ruling, Morel raced around the bases until second base umpire and crew chief Brian O'Nora signaled home run.
Morel added a two-out, two-run single in the fifth.
Giants opener John Brebbia, who also started Tuesday's win over Colorado, pitched two hitless innings with one strikeout. Brebbia also survived getting hit by a 104.9 mph line drive off the bat of Ian Happ in the second.
Cubs: OF Cody Bellinger (left knee) took batting practice and did some running before the game. … RHP Bruce Boxberger (right forearm strain) threw a 26-pitch bullpen session.
Giants: C Joey Bart was reinstated from the 10-day injured list and optioned to Triple-A Sacramento late Friday night. … RHP Scott Alexander (sore hamstring) was unavailable to play.
Cubs RHP Hayden Wesneski (2-2, 4.81 ERA) starts the finale Sunday in his first start against San Francisco. The Giants had not announced a starter.