PHOENIX (AP) David Peralta's first two ugly hacks in his final at-bat gave little indication a clutch hit was coming.
Frustrated, the Diamondbacks' cleanup man talked to himself for a few seconds, moved up a little in the batter's box and got ready for swing number three. It wasn't much better, but it was good enough.
Peralta, who homered earlier, slapped a bases-loaded single through the right side of the infield with one out in the ninth inning to push Arizona past the streaking Oakland Athletics 4-3 Monday night.
''Sometimes you don't have to hit the ball that hard to do some damage,'' Peralta said, laughing.
The Diamondbacks won their fifth straight game and are above .500 for the first time this season. They needed the ninth-inning rally after blowing a late lead.
The A's trailed 3-1 going into the eighth but came back to tie it after loading the bases with one out. Matt Chapman knocked in one run with a sacrifice fly to deep right field and then Gold Glove shortstop Nick Ahmed committed a stunning error on Matt Olson's shallow pop fly to left, dropping the ball and allowing the tying run to score.
''It's a ball that I catch 100 times out of 100 if I would do it right now,'' Ahmed said. ''I just missed it. No excuses.''
Ahmed quickly made up for his mistake, smacking a leadoff double to left field to start the decisive ninth-inning rally. Kole Calhoun went down on strikes for the first out, Ketel Marte followed with a single and the A's intentionally walked Starling Marte to load the bases.
That matched left-handed reliever Jake Diekman against the left-handed-hitting Peralta, who took a few weak swings while quickly falling behind 0-2 in the count. The game-winning swing wasn't exactly a masterpiece, but he reached across the plate and flipped the ball through the drawn-in infield.
''That's what good hitters do,'' Arizona manager Torey Lovullo said. ''Even when they don't get their best swing, they put the barrel on the ball. In this case, we're just looking for some contact. David did just enough.''
Arizona starter Zac Gallen took a no-hitter into the sixth in his 20th career start. Austin Allen's single with one out was Oakland's first hit and Marcus Semien followed with an infield single, but Gallen got out of the jam by striking out Tony Kemp and Chapman.
Gallen gave up three hits - including Robbie Grossman's solo homer in the seventh. He struck out eight, walked one and left with a 3-1 lead.
''Their starter threw the ball really well,'' Oakland manager Bob Melvin said. ''He gave us fits today. Any pitch, any count. Everything, he had us off balance. Then we get into the bullpen, we feel pretty good in the late innings, and ended up tying it up again. Not a surprise, we just couldn't finish it off.''
Oakland entered with a big league-best 16-6 record and had won 13 of its past 15 games. The Diamondbacks had been on a roll, too, winning four straight and eight of 11 to reach .500 for the first time since opening day.
Peralta homered in the third to give the Diamondbacks a 1-0 lead. He also started a rally in the sixth with a leadoff double. He scored on a fielder's choice after Kemp's throw to the plate on Eduardo Escobar's chopper was late. Carson Kelly added an RBI single to push the D-backs ahead 3-0.
Oakland's Chris Bassitt gave up three runs over 5 1/3 innings, striking out three and walking three.
Stefan Crichton (2-0) earned the win with a scoreless inning of relief. Joakim Soria (1-1) allowed Ahmed's double to start the ninth.
LAUREANO SET FOR RETURN
The A's will be eager to have CF Ramon Laureano back in the lineup Tuesday after he completed his four-game suspension by sitting out Monday's series opener. Laureano had his penalty reduced from six games to four via appeal for his role in a benches-clearing brawl with the rival Houston Astros on Aug. 9 in Oakland.
''It'll be nice to get him back. He's going crazy,'' Melvin said, noting Laureano is spending way too much time in the manager's office.
Athletics: Right-handed reliever Burch Smith had an MRI on his strained right forearm that revealed no structural ligament damage, a relief to everybody given he has had a previous Tommy John surgery. Melvin said Smith won't throw for at least two weeks and isn't sure whether he'll pitch again in the abbreviated 2020 season. ... LHP A.J. Puk, yet to pitch this season because of a strained shoulder, threw a 30-pitch bullpen using all his pitches at the club's San Jose alternate site. He will likely throw again Wednesday.
Diamondbacks: LHP Madison Bumgarner threw a 46-pitch bullpen. Lovullo said the session went well and ''he's exactly where we thought he would be.'' Lovullo said no decision had been made about when Bumgarner will be activated from the injured list. ... The team called up RHP Yoan Lopez and 1B/DH Kevin Cron and sent RHP Joel Payamps and utility man Andy Young to the team's alternate training site.
Athletics: Oakland wraps up the quick two-game series by sending RHP Frankie Montas (2-1, 1.57 ERA) to the mound.
Diamondbacks: Arizona goes with RHP Luke Weaver (0-3, 11.85), who has pitched just 13 2/3 innings this season in four starts.
AP Baseball Writer Janie McCauley contributed to this report.
More AP MLB: https://apnews.com/MLB and https://twitter.com/AP-Sports