HOUSTON — Pinch-hitter Jon Jay's tiebreaking triple in the eighth inning helped the Arizona Diamondbacks beat the Houston Astros 4-2 Friday night, 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 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.

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.

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.

TRAINER'S ROOM

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. Manager Torey Lovullo said he wasn't sure yet how long he'd be out, but that it could be a while. ... 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.

UP NEXT

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.