SAN FRANCISCO -- Justin Ruggiano hit Matt Cain's second pitch for a home run, his first of two in the game, and Nathan Eovaldi pitched into the seventh inning for his first win of the season as the Miami Marlins completed their most successful trip of the season by beating the San Francisco Giants, 7-2, on Sunday.
The last-place Marlins, who had a nine-game winning streak at San Francisco's AT&T Park snapped Saturday, beat the defending champions three times in four games to cap a 4-3 Western swing, their first winning trip of the season.
The trip began in Arizona for the Marlins, who had won a total of only eight games in five previous trips this season.
Eovaldi (1-0), who was torched for eight runs on 10 hits when he faced the Giants for the Los Angeles Dodgers last June, shut out San Francisco on two hits through five innings this time.
Then, Tony Abreu's triple and Hunter Pence's home run helped the Giants produce single runs against Eovaldi in the sixth and seventh.
Making only his third start of the season after suffering from right-shoulder inflammation during spring training, the hard-throwing right-hander was pulled two batters into the seventh, having allowed two runs on four hits. He struck out seven and walked two.
Ruggiano's first career leadoff home run staked Eovaldi to a lead even before he took the mound, and the Marlins made it 3-0 with single runs in the fourth and sixth innings.
Marcell Ozuna, who had game-winning hits in Miami victories on Thursday and Friday nights, drove in Logan Morrison with a double in the fourth.
First baseman Brandon Belt's error on a hot shot by Morrison allowed Ed Lucas to score in the sixth.
In losing for just the second time since April 18, Cain (5-4) pitched six innings, allowing the three runs on six hits. He struck out eight and didn't walk a batter for the second consecutive start.
Ozuna's second home run of the season, a leadoff blast off Jean Machi, triggered a four-run Miami ninth that iced the victory.
Pinch-hitter Greg Dobbs' two-out double scored Derek Dietrich to make it 5-2 before Ruggiano blew it wide open with his second home run, giving him his second multi-homer game of the season.
The Giants, who lost four of seven to San Diego and Miami to account for their first losing homestand of the season, finally broke through against Eovaldi in the bottom of the sixth when pinch-hitter Abreu's sliced liner down the left-field line eluded Ruggiano for a triple.
Marco Scutaro's one-out grounder to second drove in the run.
Pence's home run to lead off the seventh got the Giants within one, before reliever Ryan Webb made the biggest pitch of the game, getting pinch-hitter Joaquin Arias to hit a comebacker that became a double play with the potential tying run on third base.
Pence's home run, his 12th of the season, was the Giants' first home run in nine games, a span of 90 innings.
The Giants threatened against Chad Qualls in the eighth, but a baserunning gaffe by Scutaro short-circuited the opportunity.
After a one-out infield hit by Gregor Blanco, his second of the game, Scutaro singled to right-center, sending Blanco to third. When right fielder Giancarlo Stanton threw to third in an effort to get Blanco, Scutaro tried for second but was gunned down for the second out.
Qualls then got Buster Posey to ground to shortstop to end the inning.
NOTES: The Marlins had gone 1-5, 2-4, 3-7, 0-5 and 2-3 on their previous five trips this season. ... Justin Ruggiano's previous two-home run game came May 5 at Philadelphia. ... The Giants are 13-17 against teams with losing records. ... The Marlins and Giants have met 158 times. Eighty-nine have been decided by two or fewer runs, a 56.3 percentage that is the highest in baseball for matchups played 62 or more times. ... The Marlins are off Monday. The Giants probably wish they were. They have a big question mark for their starting pitcher Tuesday in the second game of their series in Los Angeles. Chad Gaudin, who had to leave Thursday's game against Florida after getting hit near the right elbow with a line drive, is making slower-than-expected progress, which could result in minor-leaguer Mike Kickham being promoted to make the start.