HOUSTON — In a stretch where the Arizona Diamondbacks feel like things haven't been going their way, a lucky break on Friday night helped them to a much-needed win.
Pinch-hitter Jon Jay's tiebreaking triple in the eighth inning sent them past the Houston Astros 4-2, tightening a pair of playoff races.
The AL West-leading Astros had their edge cut by Oakland to 2 ½ games. Arizona moved within three games of St. Louis and Los Angeles for the second NL wild-card spot.
It was 2-all when Nick Ahmed doubled off Hector Rondon (2-4) with one out in the Arizona eighth. Jay hit a two-out, tiebreaking drive into the right field corner and later scored when a flyball by A.J. Pollock dropped in shallow center field for a single.
The triple by Jay came on a ball he said hit twice off his bat and that he thought was probably going to be foul.
"It kind of hooked back and that's when I realized what had happened and I just ran," Jay said. "It fell through and ... that was a big break for us right there. We needed it."
Manager Torey Lovullo was impressed with the way his team persevered.
"I know that we've been dealing with some frustrating circumstances," he said. "For us to come out against the world champs and play the way we did, I was really proud of these guys."
Arizona starter Robbie Ray yielded two hits and two runs with six strikeouts in 5 1/3 innings. Brad Ziegler (2-6) pitched 1 1/3 scoreless innings and Yoshihisa Hirano allowed one hit in a scoreless ninth for his second save.
David Peralta had three hits and drove in two runs and Paul Goldschmidt doubled twice for Arizona.
Astros starter Dallas Keuchel allowed five hits and two runs in six innings.
Ray retired 13 of the last 14 batters he faced with Houston's only baserunner in that span coming when he walked Carlos Correa with one out in the fourth.
"It was frustrating," manager A.J. Hinch said. "We didn't do a ton between the first inning and the sixth inning, offensively. Ray settled in and flashed his good stuff. We did get a couple of opportunities but just couldn't break through with the big hit."
The Diamondbacks scored twice in the first when Eduardo Escobar walked, Goldschmidt hit a ground-rule double and Peralta followed with a single.
Houston came back with two in the bottom half. George Springer led off with a single, Jose Altuve and Alex Bregman walked to load the bases and Yuli Gurriel hit an RBI single. A double-play grounder by Correa tied it.
Diamondbacks: RHP Clay Buchholz, scratched from his scheduled start on Thursday with tightness in his right elbow, has a flexor strain in his right forearm and Lovullo said after the game that he won't pitch again this season. He added that he'd have more information about his condition in the coming days. ... LHP T.J. McFarland has inflammation of a bone spur around his elbow, but Lovullo said he doesn't think that it will keep him out long.
TRIPLES ON TRIPLES
Jay's triple was his fifth with the Diamondbacks this season and seventh overall. It also gave Arizona 46 triples this season which leads the majors.
SIPP KEEPS STRANDING
Houston left-hander Tony Sipp struck out David Peralta with two runners in scoring position in the seventh inning on Friday night. He's now stranded 31 of 35 runners he's inherited this season, which is the third-highest percentage in the majors.
Houston's Charlie Morton (14-3, 3.15 ERA) opposes Arizona's Zack Godley (14-9, 4.67) when the series continues Saturday night. Morton has won two straight and tied his career high for wins. Godley has dropped two in a row and allowed seven hits and five runs in four innings of a loss to the Rockies in his last start.