Davis gave up a two-run ninth inning homer to Mac Williamson and walked Michael Morris to place a potential tying run on base.
"We had them on fumes," said Giants manager Bruce Bochy.
That third strike on Panik drew Bochy's ire, but there wasn't much he could do about it.
"It was a shame to end the game on that call," he said. "They got the benefit of a bad call, that's not a strike."
"That was probably the strongest I've felt deep in a game, today was definitely the best," said Hendricks, who picked up his second straight win. "After that homer (third-inning shot by Spann) the aggressiveness picked up a little bit. That's what I've been looking for."
The win was the second in-a-row as the Cubs (24-21) now go for the series win on Thursday. The Giants (20-28) dropped their second straight and third in four.
Giants starter Matt Moore (2-5) departed after six-plus innings and took the loss. He allowed four runs (three earned) on seven hits, struck out four and walked three.
"He threw the ball fairly well," said Bochy. "He made a couple of mistakes in the middle there to Rizzo and (Rizzo) took advantage of it. (But) overall it was a good effort and he kept us in the game."
The Cubs led 3-2 after five and missed a chance for another run in the sixth. Jason Heyward appeared to beat out an infield hit to drive in Kris Bryant from second, but umpires called Heyward out for not running in the lane and Bryant was returned to second.
But Chicago added one in the seventh for a 4-2 lead as Baez reached on a fielder's-choice sacrifice and Montero scored from third on a throwing error by reliever George Kontos.
Cubs reliever Carl Edwards Jr. replaced Koji Uehara with two outs in the eighth and runners on first and second. Edwards walked Buster Posey to load the bases, but Brandon Crawford grounded to Edwards on a full count to end the threat.
Heyward tripled off the right-field wall to lead off the Cubs' eighth and scored on Jon Jay's one-out sacrifice fly to right.
The Giants opened the scoring in the second inning as Crawford doubled to lead off, reached third on Nunez's bunt single and came home when Christian Arroyo grounded into a fielder's choice to second.
Rizzo evened the score in the bottom of the second with his 10th homer of the season, a leadoff blast lined to right with none on. Span followed with a solo homer to lead off the third for a 2-1 lead.
Rizzo's second homer came in the fourth with two outs as he sent Moore's first pitch to right center to knot the score at 2. It was Rizzo's 14th career multi-homer game and first this season.
Baez gave the Cubs a 3-2 lead in the fifth with a one-out sacrifice fly to left that brought home Addison Russell from third.
NOTES: OF Denard Span was back in the lineup after missing two games with sprained thumb suffered last weekend in St. Louis. ... Giants manager Bruce Bochy said INF Aaron Hill (right forearm strain) and INF Conor Gillaspie (back spasms) could be activated from the disabled list as early as Friday when the Giants return home to face Atlanta in a three-game weekend series. ... The Giants send former Cubs RHP Jeff Samardzija (1-5, 4.57 ERA) against Chicago RHP Eddie Butler (1-0, 2.00 ERA) in Thursday's series finale. ... Cubs LHP Brett Anderson is scheduled to continue his rehab in Arizona later this week. He remains on the disabled list with a lower back strain. ... The Chicago Sun-Times reported the Cubs have renewed a request to the city to close streets outside Wrigley Field on game days as a security measure in the wake of this week's terror attacks at a concert in Manchester, England. ... The Cubs and Giants meet again in a series at AT&T Park on Aug. 7-9.