"Late Night LaMonte" finally delivered at home for San Francisco on Thursday night.

LaMonte Wade Jr. singled home the winning run with one out in the ninth inning and the Giants held their two-game lead in the NL West, beating Madison Bumgarner and the Arizona Diamondbacks 5-4.

The Giants posted their 105th victory — one off the franchise record set in 1904 — and kept their two-game edge over the second-place Los Angeles Dodgers going into the final weekend of the season. San Francisco closes with three games at home against San Diego. The Dodgers finish with three at home against NL Central champion Milwaukee.

With the score tied at 4 in the ninth, Wilmer Flores hit a one-out double off Joe Mantiply (0-3), who then intentionally walked Donovan Solano. A walk to pinch-hitter Curt Casali loaded the bases for Wade, and he singled into right field.

CLICK HERE FOR MORE SPORTS COVERAGE ON foxnews.1eye.us

Wade is 13 for 23 (.565) with 12 RBIs in the ninth inning this season, prompting teammates to begin calling him "Late Night LaMonte." Despite the reputation, this was his first walk-off hit.

"It was special, first time doing it at home," Wade said.

Wade's timely connection capped a night that started with Bumgarner's first outing in front of fans in San Francisco since he signed a free agent deal with Arizona prior to the 2020 season. He settled for a no-decision, and the 2014 World Series MVP saw flashes of the three championship teams he was a part of with the franchise.

"It’s pretty crazy. It’s pretty incredible to see," Bumgarner said. "I know people have counted them out all year and a lot of people can’t understand it and make sense out of it, but I’ve been on that side when people are saying the same thing. I know how dangerous the Giants are just in general when they get in the postseason. I’ve obviously seen that a time or two, so there’s something about that uniform, I don’t know."

Tyler Rogers (7-1), San Francisco's sixth reliever, pitched two innings for the win.

Johnny Cueto entered in relief for the first time in his career after coming off the injured list earlier in the day and pitched 2 1/3 innings for the Giants, allowing one run and three hits with three strikeouts.

"It was big for him to give us a couple innings there," catcher Buster Posey said. "I’m sure as long as he’s been in the big leagues it had to be obviously a very different feel coming out of the bullpen, but it was same Johnny attacking, mixing."

Ildemaro Vargas hit a go-ahead triple in the Arizona fifth before Posey's double in the bottom half made it 4-all.

Brandon Crawford homered in the fourth off his former longtime teammate MadBum, who helped the Giants win championships in 2010, ‘12 and ’14.

Posey hit a sacrifice fly against Bumgarner in the third.

Bumgarner was recognized at Oracle Park in August but didn't pitch that series. He did face the Giants on his old mound during the coronavirus-shortened 2020 season but with cardboard cutouts in the stands instead of real people.

The star lefty allowed eight hits and four runs over five innings, struck out four and didn't walk a batter. He hasn't won since Aug. 19 against the Phillies, going 0-3 over his last seven outings.

Bumgarner drew a warm ovation during pregame introductions, then again when he stepped into the batter's box in the first and before he threw his first pitch.

"Super familiar feeling. Honestly it felt like I’d done it a couple hundred times or whatever it was," Bumgarner said. "It was really cool. This place, I’ve said it a bunch, it means a lot to me and my family. I don’t take that for granted by no means. I enjoyed that and I’m very thankful for that. It’s special."

Bumgarner signed an $85 million, five-year contract with Arizona after the 2019 season and 11 years with the Giants.

Austin Slater greeted Bumgarner with a leadoff single and Darin Ruf followed with an RBI double.

Carson Kelly and Pavin Smith hit RBI singles in the fourth straight defeat for the D-backs (50-109), who finished with a 20-61 road record that included a record 24-game skid away from Chase Field.

Arizona went 0-9 at San Francisco this season and is two losses from the franchise record of 111 in 2004.

After Crawford's dazzling stop at shortstop on Ketel Marte's grounder leading off the game, Scott Kazmir issued back-to-back walks before three straight singles.

Kazmir exited his fourth start and fifth appearance after recording just one out, injured when he hustled to cover first on an infield single. Kervin Castro relieved and issued a bases-loaded walk that made it 3-0.

TRAINER'S ROOM

Giants: Cueto will be used out of the bullpen for now after dealing with elbow issues this year. "I’ll be myself," Cueto said. "Of course, I’ll be a little bit more aggressive because I know it’s going to be maybe one inning or two."... Ruf also was activated from the IL and back in the lineup playing left field batting second. ... LHP Tony Watson was placed on the 10-day IL retroactive to Wednesday with a strained pitching shoulder.

ROSTER MOVE

The Giants designated LHP José Quintana for assignment.

UP NEXT

Diamondbacks: Will send RHP Humberto Castellanos (2-2, 4.28 ERA) to the mound Friday night back at home against Colorado for his seventh start and 14th appearance of the year.

Giants: RHP Anthony DeSclafani (12-7, 3.26) pitches Friday night's series opener against San Diego seeking just his second win in eight starts since Aug. 13.