Giancarlo Stanton, J.T. Realmuto power Marlins past Giants to avoid sweep

SAN FRANCISCO (AP) -- Miami manager Don Mattingly thinks slugger Giancarlo Stanton took an encouraging step with his third multihit game of the season.

Stanton was more pleased with helping the struggling Marlins get a much-needed win -- just the team's third in the last 11 games.

"It's good for us," said Stanton, who had three hits -- including his fourth home run -- in Miami's 5-4 win over the San Francisco Giants on Sunday.

"Everyone contributed, too. That's the big part. Not just one getting one big day from one guy."

Stanton reached base four times and J.T. Realmuto matched his career high with four hits, including a tiebreaking home run in the eighth inning. Christian Yelich drove in two runs, and Dee Gordon and Marcell Ozuna had two hits apiece for Miami.

It was a much-needed shot in the arm for Mattingly's ballclub, which has struggled through the first month of the season. Mattingly was ejected on Friday and the Marlins suffered back-to-back lopsided defeats before bouncing back to avoid their first three-game sweep by the Giants since 2010.

"It seems like every win we've been getting this year has been a good one," Mattingly said. "Then we've had other chances to really put some wins together and we really haven't been able to do that. You can't win two without winning one, so it's really good to get that one on the board today."

San Francisco loaded the bases with no outs in the bottom of the eighth but failed to score. David Phelps got Angel Pagan to ground into a 1-2-3 double play before getting Joe Panik to strike out looking.

Hunter Pence homered for the Giants, who fell to 2-5 on their 10-game homestand.

Realmuto had been hitless in 15 at-bats at AT&T Park before singling twice and doubling off Giants starter Matt Cain. His homer off reliever Josh Osich (0-1) was his first since Sept. 16.

Kyle Barraclough (1-0), the fourth of six Miami pitchers, retired three batters for the win. A.J. Ramos worked the ninth for his third save.

Stanton homered leading off the top of the fourth. Pence countered in the bottom of the frame with his own leadoff home run.

"Anyone can have a day," Stanton said. "I've got to put it together a few times in a row before you want to talk about a relief."

San Francisco scored twice in the sixth on singles by Brandon Belt and Pagan to erase a 4-2 deficit before Realmuto's winner in the eighth.

Cain allowed four runs over 5 2/3 innings with four strikeouts and two walks.

"It was encouraging," Giants manager Bruce Bochy said. "He battled well. That should do a lot for him."

CONLEY NOT CRISP

Mattingly was mostly satisfied with the outing from starting pitcher Adam Conley but acknowledged the left-hander seemed to tire later in the game. Conley gave up four runs in 5 2/3 innings and walked four with two strikeouts. "I don't think he had quite his really, really good stuff," Mattingly said. "As the game went on it looked like he labored a little bit more."

TRAINER'S ROOM

Giants: CF Denard Span, who is hitting .350 on this homestand, walked as a pinch-hitter in the eighth. Span did not start for just the second time this season after being limited to a career-low 61 games because of injuries in 2015. ... Belt was also held out of the lineup before pinch-hitting in the sixth.

UP NEXT

Marlins: LHP Wei-Yin Chen (0-1) pitches Monday in the opener of a four-game series with the Dodgers.

Giants: LHP Madison Bumgarner (1-2) starts against San Diego on Monday at AT&T Park. Bumgarner pitched into the seventh inning in his last outing, the first time he's done that this season.