Gallen (9-2) limited the Giants to four hits and has now thrown 21 1/3 consecutive scoreless innings. The right-hander has won five straight decisions since his last loss on June 10 at Philadelphia.
''He was feeling it,'' Arizona manager Torey Lovullo said. ''It was just a pretty dominating performance.''
Added Gallen: ''I just feel like I was ahead early and then I felt like I was just able to put them away in one or two pitches, pretty much limit the pitch count.''
Daulton Varsho, Josh Rojas, Sergio Alcantara, Jake McCarthy and Carson Kelly drove in runs for the D-backs, who chased Logan Webb (11-6) early and earned a split of the four-game series.
Webb gave up five runs, three of them earned, on nine hits and three walks in 4 2/3 innings.
''I thought our offense did a great job,'' Lovullo said. ''We had an all-field approach. We really dug in in some crucial situations and didn't give up our at-bats.''
Varsho singled home Alcantara to start the scoring in the third. Rojas added an RBI double later in the inning.
Alcantara's RBI groundout in the fourth made it 3-0. McCarthy and Kelly singled home runs in the fifth.
''We swung the bats well, kept adding on and played pretty good defense,'' Gallen said.
San Francisco's best chance to score came in the seventh when Joc Pederson singled and Evan Longoria doubled to put runners on second and third with two outs. But Brandon Belt struck out on a failed two-strike bunt attempt, ending the inning and drawing boos from the frustrated Oracle Park crowd.
''From my point of view, I've been struggling a little bit,'' Belt explained. ''(Gallen) was tough all day. ... I took the best route that I thought would keep the inning going. I'm not saying I'm right about that, but that was the decision I made. I felt very comfortable bunting. I wanted to keep that inning going. I just didn't get it down.''
The Giants have lost two in a row following a five-game winning streak. The Diamondbacks have won four of their last six.
''This is an important win,'' Lovullo said. ''We haven't won a lot in this venue. I don't want the guys to shut down, so I was really trying to trigger them and tell them, ''We've got to stay on this, let's keep going.'''
Rojas was picked off first base by left-hander Thomas Szapucki in the seventh inning. It was recorded as a caught stealing, ending Rojas' run of 17 consecutive successful stolen bases this year, matching Tim Locastro for the longest streak to start a season in Diamondbacks history.
MISSING THE K
Thursday marked Webb's first career start without at least one strikeout. The only other appearance where he failed to record a strikeout came in relief on Sept. 27, 2020, against the San Diego Padres when he got just one out.
''They've got a sneaky-good lineup,'' Webb said. ''I had a lot of 0-2 counts today. I was getting ahead, but I couldn't finish them off.''
Diamondbacks: 2B Ketel Marte remained out of the starting lineup for a fourth straight game with tightness in his left hamstring. He was used as a pinch-hitter on Wednesday, grounding out sharply to shortstop in the seventh inning.
Diamondbacks: Rookie LHP Tommy Henry (2-1, 4.15 ERA) makes his fourth career start as Arizona returns home for a three-game series against the St. Louis Cardinals on Friday.
Giants: LHP Alex Wood (8-9, 4.18) opens a three-game series at Colorado on Friday.
More AP MLB: https://apnews.com/hub/mlb and https://twitter.com/AP-Sports
Copyright 2022 STATS LLC and Associated Press. Any commercial use or distribution without the express written consent of STATS LLC and Associated Press is strictly prohibited.