The Diamondbacks’ Jordan Lawlar wore a bubble gum bucket atop his head as if it were a hat. The distance a mob of teammates traveled to celebrate with him was greater than how far his game-winning hit traveled.

No matter. Lawlar did not care. The Diamondbacks had won another game — and they had made their postseason dreams feel more possible than ever.

“Everybody’s goal in here is to make the playoffs,” Lawlar said, “and go on a magical run like ’23, you know?”

The Diamondbacks beat the San Francisco Giants, 6-5, on Tuesday night, Sept. 16, winning a game in a sort of stubborn fashion. They fell behind early, fought back to draw even, whiffed on innumerable scoring opportunities, then finally scored the walk-off run in the bottom of the ninth on a ball that traveled maybe 70 feet.

They won with a relentless offense that kept creating opportunities, with a bullpen that allowed just one baserunner over four scoreless innings, with a defense that made all the plays. And they won thanks to a Giants team that could do none of those things nearly so well.

The win not only allows the Diamondbacks to maintain pace with the New York Mets for the third wild-card spot — the Mets beat the Padres, 8-3, earlier in the evening — it also clinched the season series against the Giants, a potentially important distinction for tiebreaking purposes.

The Diamondbacks — a team that lost its top starting pitcher and several of its top relievers to season-ending injuries, a team that sold five veterans off its roster at the trade deadline — are 1 1/2 games out of a playoff spot with 10 games remaining in their season.

“It’s getting real,” Diamondbacks manager Torey Lovullo said. “That’s what I can say. It’s getting real. But we’ve got to keep grinding. We’ve got to keep doing the things that we do.”

After blowing scoring opportunities in the sixth, seventh and eighth innings, the Diamondbacks finally snapped a 5-5 tie in the ninth when Lawlar’s slow roller to the right of the mound squirted past pitcher Ryan Walker, giving the speedy Corbin Carroll time to race home with the winning run.

“I knew he was going to do it,” third baseman Blaze Alexander said of Lawlar. “Whether it was going to be a deep fly ball or something, I’ve played with him too many times down in Reno — he gets the job done in those situations.”

The Diamondbacks were down 4-0 after the top of the first, an inning in which the Giants collected five hits, including a pair of doubles, off left-hander Eduardo Rodriguez. After the Giants scored another run in the third, Rodriguez settled in and got through five innings, handing off to a bullpen that retired the final 12 batters.

Adrian Del Castillo’s two-run homer capped a three-run second inning for the Diamondbacks, who tied the game three innings later on back-to-back run-scoring singles from Carroll and Ketel Marte.

“We’re always in it,” Alexander said. “We’re never out of it. We’re grinders. It’s what we do. We make it tough on opposing pitchers. We’re going to work them.”

Jake McCarthy made a rangy catch in left-center field to steal a hit from Heliot Ramos in the fourth. Two innings later, center fielder Alek Thomas raced in to take a hit away from Jung Hoo Lee with a sliding grab. The Diamondbacks made all the routine plays, as well.

That could not be said of the Giants, who botched a number of plays on the infield, including two in the ninth inning. With runners on first and second and nobody out, second baseman Casey Schmitt inexplicably took his foot off the bag while catching a throw at first on an Alexander sac bunt.

That loaded the bases, setting the stage for Lawlar’s squibber, a ball that Walker had sneak under his outstretched glove. It was scored a single.

“This is a fun lineup,” Lawlar said. “We mess around and say, ‘Never say Die-mondbacks.’ We’re always grinding out at-bats and just getting the bat to the next guy. Just get on base and anything can happen.”

At 77-75, the Diamondbacks are two games over .500 for the first time since June 25. They still have a tough road ahead, with series remaining against the Philadelphia Phillies, Los Angeles Dodgers and San Diego Padres, and are going to need the New York Mets to continue to flounder, but a trip to the postseason no longer feels so far-fetched as it once did.

“On one hand, we still need the Mets to lose,” Carroll said. “On the other hand, we’re right in there. We’ve got to keep playing well and stacking wins in order to get in. Just everyone’s very focused and, at the same time, still having fun.”

Lovullo says Perdomo deserves MVP push

A day after watching his shortstop collect three hits and reach base five times in a crucial win, Diamondbacks manager Torey Lovullo stumped for Geraldo Perdomo as a most valuable player candidate in the National League.

“Without a doubt,” Lovullo said. “He leads the National League in WAR (wins above replacement) in some publications. That’s minus (Shohei) Ohtani’s pitching WAR.”

He added: “That absolutely should give him some consideration, for sure.”

Perdomo is having what is easily the best season by a shortstop in Diamondbacks history. He also is having one of the better seasons of anyone in the National League.

Entering the second game of a three-game series with San Francisco on Tuesday, Sept. 16, Perdomo was hitting .290/.391/.462 with 19 homers, 97 RBIs and 26 stolen bases. His 6.6 WAR is tops among position players in the NL, per Baseball-Reference. As Lovullo noted, the Dodgers’ Ohtani ekes out Perdomo in total WAR; he has accumulated 6.3 WAR as a hitter/baserunner and another 0.4 WAR in 36 innings on the mound.

“I know the league is taking notice of him,” Lovullo said of Perdomo. “Some of the other staff members, some of the other managers, a lot of them ask me about Perdomo often. What you see is what you get, and when you get a little bit deeper, it gets even better.”

Ketel Marte working way through slump

Lovullo said second baseman Ketel Marte is dealing with a slump at the plate, but that his teammates have managed to pick up the slack for him.

“Maybe trying to do too much, a little bit of chase,” Lovullo said. “I have not talked to him personally, but I’ve been thinking about it, just to slow the game down and not try to do too much.

“He’s got a championship mentality. He wants to be the guy in the middle of everything. But sometimes this game is hard and you just don’t have a feel for your swing. I think that’s where he’s at right now. That’s why he has teammates.”

Marte went hitless in four at-bats with a hit by pitch in the series-opening win over the Giants. He saw a total of eight pitches in the five trips to the plate.

Marte is 5 for 40 (.125) with a double and four walks over his past 10 games.

Lovullo was asked if the right foot contusion that sidelined him for a day over the weekend in Minnesota might be hindering him at the plate.

“I think so,” Lovullo said. “He can’t get out to that front side when he’s hitting left-handed. He’s assured me and the rest of the people around him that he feels fine and he wants to play.

“I don’t want to get in the way of that. We need him out on the field.”

Coming up

Sept. 17: At Chase Field, 12:40 p.m., Diamondbacks RHP Brandon Pfaadt (13-8, 5.31) vs. Giants RHP Justin Verlander (3-10, 3.94).

Sept. 18: Off.

Sept. 19: At Chase Field, 6:40 p.m., Diamondbacks RHP Ryne Nelson (7-3, 3.34) vs. Phillies RHP Walker Buehler (8-7, 5.29).

Sept. 20: At Chase Field, 5:10 p.m., Diamondbacks RHP Nabil Crismatt (3-0, 2.70) vs. Phillies RHP Taijuan Walker (5-8, 4.17).

(This story has been updated to add new information.)