The Diamondbacks (70-58) took three of four from the Mets and reamined in the first National League wild-card spot.
The Mets (55-71) went 2-6 on an eight-game homestand and lost yet another key player to injury Thursday, when All-Star outfielder Michael Conforto suffered a dislocated left shoulder while swinging and missing in the fifth inning. The Mets have placed 22 players on the disabled list this season.
Ray (10-5), who suffered a concussion when he was hit in the head by a 108 mph line drive in his previous start July 28, allowed one run on two hits and two walks while striking out nine. He struck out the side on 12 pitches in the first and didn't allow a hit until Yoenis Cespedes homered leading off the fourth.
Four relievers combined to finish the five-hitter, with Fernando Rodney earning his 30th save despite issuing a pair of walks (one intentional) in the ninth. Rodney retired Wilmer Flores with runners at the corners for the final out.
Ray also contributed to the Diamondbacks' two-run fifth inning, when he had the third of four straight singles off Mets starter Rafael Montero. Gregor Blanco followed with an RBI single to score Reymond Fuentes (2-for-3) before Ketel Marte lofted a sacrifice fly to bring home Chris Herrmann.
The Diamondbacks added a run in the sixth, when Paul Goldschmidt led off with a single, stole second and scored on Brandon Drury's one-out single.
Brandon Nimmo, who replaced Conforto, delivered an RBI groundout in the seventh for the Mets. Cespedes and Kevin Plawecki had two hits apiece.
Montero (2-9) took the loss after allowing the three runs on seven hits and two walks while striking out five over 5 1/3 innings.
NOTES: To make room on the 25-man roster for LHP Robbie Ray, the Diamondbacks optioned RHP Matt Koch to Triple-A Reno. ... Diamondbacks SS Nick Ahmed (broken right hand) is scheduled to play his fourth rehab game for the rookie-level Arizona League Diamondbacks on Thursday night. Diamondbacks manager Torey Lovullo said it could be the final game for Ahmed before he is moved to Reno. ... The Mets announced RHP Zack Wheeler (shoulder) will not pitch again this season and that RHP Tyler Pill (elbow) underwent elbow surgery Wednesday. ... Mets RHP Noah Syndergaard (torn right lat) is scheduled to throw batting practice at the team's spring training complex in Florida on Friday.