PHOENIX — Cody Ross hit a three-run, pinch-hit home run in the eighth inning to spoil an outstanding outing by Miami's young Jose Fernandez, and the Arizona Diamondbacks held off the Marlins 3-1 Wednesday.

Fernandez (4-4) retired 14 in a row before walking two of the three batters he faced in the eighth. He was relieved by left-hander Mike Dunn, who gave up the home run to Ross on a 1-2 pitch.

Arizona starter Trevor Cahill left after a line drive bruised his right hip in the first. Josh Collmenter allowed one hit in six innings of relief.

Justin Ruggiano homered off Heath Bell to start the ninth. Bell held on to get his 13th save in 15 tries.

Bell flirted with bigger trouble.

After Ruggiano's homer, Ed Lucas singled to bring up Giancarlo Stanton, whose home run off Bell on Friday gave Miami a 3-2 victory. Stanton walked on five pitches to put runners on first and second with no outs.

Bell got Marcell Ozuna on a flyout, catcher Miguel Montero made a nice sliding catch of Derek Dietrich's foul to the screen and pinch-hitter Logan Morrison struck out to give Arizona two of three against Miami.

David Hernandez (4-4) pitched a scoreless eighth to get the victory.

Fernandez, the 20-year-old Cuban refugee, allowed two runs on three hits with four strikeouts and those two costly late walks in 7 1-3 innings.

Collmenter struck out seven and walked one. He retired 13 in a row, striking out the side in the fourth, before Stanton singled to start the seventh. Stanton was stranded when Ozuna struck out, Dietrich popped out and Adieny Hechavarria flied out.

After Collmenter's infield single to lead off the third, Fernandez didn't allow another runner until Jason Kubel drew a leadoff walk on a 3-2 pitch in the eighth. A.J. Pollock popped to the catcher on a foul trying to advance the runner with a bunt, then Didi Gregorius walked to put runners at first and second with one out.

That ended Fernandez's outing.

Initially, left-handed batter Alex Hinske was announced as the pinch-hitter. But when the left-handed Dunn came on, manager Kirk Gibson switched to Ross, who his his fifth career pinch-hit homer and first since 2008.

Cahill, who had lost his previous three starts, took a lined shot off his right hip off the bat of Ozuna. The ball careened off Cahill to third baseman Martin Prado, who threw the runner out to end the inning. Cahill came out for the second inning and had a 2-1 count on Dietrich when the trainer came out and, after some discussion, the pitcher left the game.

Only one baserunner got as far as second through the first seven innings. That came in the first against Cahill, when Ruggiano advanced from first on a groundout.

NOTES: Arizona's Gerardo Parra was thrown out trying to steal second in the third inning. That leaves him 6 of 15 on stolen base attempts. ... Miami moves on to San Francisco, opening a four-game series with the Giants on Thursday night. RHP Tom Kohler (0-5, 5.09 ERA) goes for the Marlins, RHP Chad Gaudin (2-1, 2.83) for San Francisco. ... The Diamondbacks are off Thursday, then conclude a six-game homestand with three against Cincinnati. LHP Wade Miley (4-6, 4.64) starts Friday's opener for Arizona, with RHP Johnny Cueto (4-0, 2.08) going for the Reds.