Robbie Ray pitched 5 2/3 innings of no-hit ball, Jake Lamb hit a crucial three-run double and the Arizona Diamondbacks rallied for a 7-5 victory over the Miami Marlins on Monday night.

Arizona, clinging to slim postseason hopes, remained 5½ games back of the Chicago Cubs for the second NL wild card with 11 to play and also would have to leapfrog Milwaukee, Philadelphia and the New York Mets.

At 52-98, the NL-worst Marlins matched their loss total of last year and appear headed to their first 100-defeat season since 2013.

Arizona Diamondbacks starting pitcher Robbie Ray throws against the Miami Marlins during the sixth inning of a baseball game, Monday, Sept. 16, 2019, in Phoenix. (AP PhotoRoss D. Franklin)

Arizona Diamondbacks starting pitcher Robbie Ray throws against the Miami Marlins during the sixth inning of a baseball game, Monday, Sept. 16, 2019, in Phoenix. (AP PhotoRoss D. Franklin)

Ray had his no-hit bid stopped in the sixth when Starlin Castro sent the left-hander's 86th pitch up the middle for single. Arizona led 3-0 at the time.

Ray was replaced in the seventh after walking the leadoff batter, and Yoan López allowed a two-run homer to pinch-hitter Neil Walker.

López then gave up a single and a walk before being replaced by left-hander Andrew Chafin, who faced left-handed-hitting Magneuris Sierra. The speedy Sierra dropped a perfect bunt down the third-base line and Chafin — who wasn't going to get Sierra out anyway — made an errant throw to first that scored Lewis Brinson with thw tying run.

Miami Marlins third baseman Jon Berti gets set to scoop a grounder hit by Arizona Diamondbacks' Nick Ahmed before throwing to first base for the out during the fourth inning of a baseball game, Monday, Sept. 16, 2019, in Phoenix. (AP PhotoRoss D. Franklin)

Miami Marlins third baseman Jon Berti gets set to scoop a grounder hit by Arizona Diamondbacks' Nick Ahmed before throwing to first base for the out during the fourth inning of a baseball game, Monday, Sept. 16, 2019, in Phoenix. (AP PhotoRoss D. Franklin)

Jon Berti hit a two-run single off right-hander Yoshihisa Hirano, the fourth pitcher of the inning, to push the Marlins ahead 5-3.

Then it was the Marlins turn to have a pitching breakdown.

Arizona sent eight batters to the plate in the seventh, punctuated by Lamb's two-out double down the right-field line. Lamb entered batting just .199, but the 28-year-old had a big moment just when the Diamondbacks needed it.

Miami Marlins pitching coach Mel Stottlemyre, right, visits Marlins starting pitcher Pablo Lopez, center, along with catcher Jorge Alfaro (38) during the first inning of a baseball game against the Arizona Diamondbacks, Monday, Sept. 16, 2019, in Phoenix. (AP PhotoRoss D. Franklin)

Miami Marlins pitching coach Mel Stottlemyre, right, visits Marlins starting pitcher Pablo Lopez, center, along with catcher Jorge Alfaro (38) during the first inning of a baseball game against the Arizona Diamondbacks, Monday, Sept. 16, 2019, in Phoenix. (AP PhotoRoss D. Franklin)

Ketel Marte hit an RBI double and Eduardo Escobar hit a solo homer for his 35th of the season.

Hirano (5-5) pitched a scoreless inning, and Kevin Ginkel got three straight outs for his first big league save. Tayron Guerrero (1-2) gave up three runs, two hits and a walk without getting any outs.

OUCH

Arizona set a team record when Wilmer Flores, Josh Rojas and Jake Lamb were hit by pitches in the same inning by Pablo López. Flores was hit on the shoulder while Rojas and Lamb were both hit on a foot by breaking balls. Lamb was hit with the bases loaded, scoring Flores for a 1-0 lead.

TRAINER'S ROOM

Marlins: Miami claimed LHP Josh Smith off off waivers from Cleveland and threw a scoreless eighth inning. The 29-year-old pitched eight games in relief this season for the Indians, striking out 12 over 8 1/3 innings.

Diamondbacks: Ray pitched well after battling a blister on the middle finger of his throwing hand over the last two starts. He lasted just two-thirds of an inning against the Mets on Sept. 11, giving up five runs. ... SS Nick Ahmed left the game in the eighth inning with what appeared to be a hand injury.

UP NEXT

Marlins: Miami sends LHP Caleb Smith to the mound. He's got an 8-10 record with a 4.13 ERA.

Diamondbacks: Arizona LHP Alex Young will make his 14th start. He is 7-4 with a 3.38 ERA and set a club rookie record by striking out 12 against the Reds on Sept. 7.

More AP MLB: https://apnews.com/MLB and https://twitter.com/AP_Sports