By JONATHAN DALTON

Associated Press

PHOENIX (AP) — Paul Goldschmidt had a pretty good idea that he'd just won the game for the Arizona Diamondbacks.

Goldschmidt hit a leadoff home run in the bottom of the ninth inning and the Diamondbacks ended a four-game losing streak, beating the Miami Marlins 3-2 Tuesday night.

"I had a good feeling it was going out," Goldschmidt said. "If not, it wasn't going to be a triple. I wasn't running that hard. I'm glad it got out of here."

Goldschmidt's home run bounced high off the batter's backdrop in deep center field. His 17th homer of the season was his second in as many nights, and the second game-ending home run of his career.

"I just said to Penny (infielder Cliff Pennington), `Let's have another Goldy party,' and then he hit it," Arizona manager Kirk Gibson said. "You always think that way."

Martin Prado also homered for the Diamondbacks, who snapped a season-high four-game losing streak.

David Hernandez (3-4) threw a perfect top of the ninth for the win. Chad Qualls (2-1) lost for the first time in 27 appearances, with Goldschmidt connecting on his second pitch.

"Any time it's a walkoff, whether it's you or one of the other guys, it's fun," Goldschmidt said.

Nathan Eovaldi, activated from the disabled list and making his first start since Sept. 30, scattered three hits over six innings for the Marlins, who had won two in a row.

"It felt good getting back on the mound," Eovaldi said. "This is the best my fastball has felt, locating it and everything. With my offspeed, it's still a little timing issue and I'm rushing it a little bit."

Miami has won three straight only twice this season.

"We really never got anything going and they got the big hit today," Marlins manager Mike Redmond said.

The Marlins took a 2-0 lead in the fourth against Randall Delgado. Derek Dietrich hit an RBI triple and scored on Adeiny Hechavarria's single.

Eovaldi, who had missed the season's first two-plus months with inflammation in his right shoulder, walked Miguel Montero with two outs in the fourth and Prado followed with his first homer since April 29.

"I was just looking for a fastball and to put a good swing on it," Prado said. "He tried to come in and I knew I was ready for the fastball and it went out."

Delgado, recalled from Triple-A earlier Tuesday, gave up two runs on eight hits and struck out six in seven innings.

"When he came up and threw last time he wasn't as aggressive as he could be," Gibson said. "But you could see he shortened his motion and focused on locating the ball more. I think in spring training we were looking at a guy who was more of a thrower."

NOTES: Prado's home run was his first in 167 at-bats spanning 44 games. … To make room for Eovaldi, the Marlins optioned LHP Edgar Olmos to Double-A Jacksonville. … The Diamondbacks optioned RHP Charles Brewer to Triple-A Tucson to make room for Delgado. … It was Delgado's 25th career start and first with Arizona. The right-hander came to the Diamondbacks in January in a trade that also brought Prado to Arizona for Justin Upton. … Delgado had pitched once before for Arizona this season, allowing two runs on four hits in two innings after being recalled when RHP Brandon McCarthy was placed on the 15-day disabled list. … McCarthy, on the 15-day DL with right shoulder inflammation, threw on flat ground from 105 feet on Tuesday. … Diamondbacks RHP Trevor Cahill will try to snap a three-game losing streak Wednesday afternoon when he faces RHP Jose Fernandez and the Marlins.

(Copyright 2013 by The Associated Press. All Rights Reserved. This material may not be published, broadcast, rewritten or redistributed.)

Join our Newsletter for the latest news right to your inbox