MIAMI -- Marcell Ozuna said he felt he hadn't had a hit in "thirty or forty" at-bats.

Actually, the Miami Marlins center fielder's slump reached 0-for-16 until he singled in the fourth inning.

Then he took it up several notches, powering a walk-off double to center in the 10th inning to lead Miami to a 5-4 win over the Arizona Diamondbacks on Thursday night at Marlins Park.

"That was exciting," Ozuna said after his first career walk-off hit. "It was a long time since I got a base hit. Every time it was a ground out or a strikeout. To get a line drive in that situation, I feel great."

The Marlins' winning rally came against reliever Bradin Hagens (0-1), who was making his major league debut. Hagens walked his first batter -- first baseman Garrett Jones -- on four pitches and allowed a single to catcher Jeff Mathis.

That set up Ozuna for his winning hit. He took the first three pitches for balls and then heard someone from his dugout yell for him to take another pitch.

He did that -- twice -- and Hagens got strikes to work the count to 3-2.

"He threw me two curve balls in a row," Ozuna said, "and then I said, '(expletive), I'm going to put the ball in play up the middle.' Then when I got the hit, I said, 'Thank God.' "

Marlins reliever Mike Dunn (10-5) earned the win. Dunn, who pitched two scoreless innings, set a franchise single-season record with 10 wins by a reliever.

The Marlins rallied from a 4-2 deficit with the help of a pair of two-out hits by shortstop Adeiny Hechavarria -- a triple in the sixth and a single in the eighth.

"'Hech' has improved so much," Marlins manager Mike Redmond said of his shortstop. "He's a special player."

Miami (60-61), which started the day 4 1/2 games out of the National League wild-card race, won for the fifth time in seven games.

Arizona (52-69), which is out of playoff contention, lost for the third time in four games.

Diamondbacks manager Kirk Gibson was asked about using the untested Hagens in the 10th inning.

"Who else did you want me to use?" Gibson responded before explaining that he was out of pitching after having played a 21-inning doubleheader on Wednesday.

Both starting pitchers -- Arizona rookie right-hander Chase Anderson and Miami veteran right-hander Brad Penny -- were left with no-decisions. Penny, 36, was making his first home start for the Marlins since 2004.

Arizona opened the scoring in the first inning. Center fielder Ender Inciarte led off with a four-pitch walk, stole second and came around to score on first baseman Mark Trumbo's two-out, two-strike single.

The lead stretched to 3-0 in the third inning. Second baseman Cliff Pennington drew a two-out walk and scored on right fielder David Peralta's triple to right-center field. Trumbo picked up his second RBI of the night with another clutch single.

Miami scored twice in the bottom of the third, thanks in part to Penny's double -- his first MLB hit since 2010 and his first two-bagger since 2007. The Marlins cashed in with a pair of two-out RBIs -- a double by second baseman Donovan Solano and a single by right fielder Giancarlo Stanton.

In the sixth, Trumbo walked, stole second and scored on catcher Miguel Montero's double off the fence in left, giving Arizona a 4-2 lead.

"We actually made pretty good use of our opportunities," Gibson said. "We only got six hits. We manufactured some runs, but we have to put more pressure on them."

Miami closed to within 4-3 in the bottom of the sixth. Jones led off with a walk and scored on Hechavarria's two-out triple.

The Marlins nearly tied the score in the seventh when Stanton hit a line shot to right that would have been a home run had it stayed fair. Stanton then struck out.

Miami tied the score in the eighth on Hechavarria's single, capping a rally that started with a two-out walk by catcher Jarrod Saltalamacchia.

NOTES: Arizona CF Ender Inciarte extended his hit streak to a career-high 14 games. ... After making two errors Wednesday, Marlins 2B Jordany Valdespin was benched Thursday in favor of Donovan Solano. ... Besides the errors by Valdespin, another reason to start Solano is that he entered Thursday 11-for-22 with five RBIs in six career games against Arizona. ... In 43 previous MLB games at 2B, Valdespin had only made two errors, so what happened Wednesday might have been an aberration. ... Five of Arizona's starters Thursday began the year in the minors: LF Xavier Paul, CF Ender Inciarte, RF David Peralta, 3B Jake Lamb and RHP Chase Anderson. ... Arizona has nine players now on the disabled list and 15 for the season, totaling more than 1,000 days. ... The Diamondbacks have spent all but one day this season in either fourth or last place. The other day, they were in third.