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.

READ MORE: Celtics torch Heat early, even series with 102-82 blowout

“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.

READ MORE: Miami Beach’s Deauville Hotel, made famous by the Beatles, poised for a comeback

“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.”

MORE NEWS: Property insurance changes aimed at stabilizing market

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