SAN FRANCISCO -- An error by a shortstop who hadn't committed one in 33 games combined with a pinch-hit home run by a backup catcher who never previously went deep proved to be a winning combination Sunday.
That's how hot the Miami Marlins are these days.
Pinch hitter A.J. Ellis and Giancarlo Stanton hit home runs in a three-run top of the 11th inning, lifting the Marlins to a 10-8 victory over the San Francisco Giants and a sweep of a three-game series.
Stanton also homered in the fifth inning, reached base a total of six times and scored four runs for the Marlins, who completed a 6-4 road trip with five wins in the last six games.
"I hope it says it's going to be a good one," Marlins manager Don Mattingly said of the potential impact of the club's first road sweep on the second half of the season.
The sweep also was Miami's first in San Francisco since May 2012.
"We've talked about trying to keep things in perspective," Mattingly continued. "There's a long way to go. We can be the team that goes out and rattles off games."
The Giants (34-56) enter the All-Star break on a four-game losing streak and with the second-worst record in the majors.
"It's been a tough first half," Giants manager Bruce Bochy said. "You try to fix a hole in the dyke and another springs open."
Ellis' homer off right-hander George Kontos (0-3), the seventh Giants pitcher, came one out after a two-base throwing error by San Francisco shortstop Brandon Crawford on an inning-opening grounder by J.T. Realmuto.
The error by Crawford, whose .993 fielding percentage at day's start was best in the majors among shortstops, was just his second miscue in his past 66 games.
Down 0-2 in the count, Ellis got just enough of a Kontos breaking ball to bounce it off the top of the wall in left field for his first homer in 25 career pinch-hitting appearances.
"The big at-bat was (JT) Riddle getting the guy over (to third base)," Ellis said of his teammate's deep fly to right field that advanced Realmuto. "I just tried to put the ball in play, get it to the outfield. That helped."
Stanton followed two batters later with his solo shot to left field, completing his 23rd career multi-homer game and giving Miami a 10-7 lead.
The right fielder has 26 homers on the season, tied for the third most in franchise history at the All-Star break.
"Our offense is as dangerous as any in baseball," Ellis said. "There's lots to be excited about going forward."
Right-hander Nick Wittgren (2-1) got the win after retiring all six Giants he faced in the ninth and 10th innings. He struck out four.
Marlins closer AJ Ramos posted his 17th save despite allowing a run in the bottom of the 11th after center fielder Christian Yelich lost pinch hitter Kelby Tomlinson's inning-opening fly ball in the sun for a triple. Tomlinson scored on a groundout.
The Giants scored three times in the bottom of the eighth inning to draw even at 7.
Crawford, Nick Hundley and pinch hitter Miguel Gomez had RBI singles in the inning before right-hander Junichi Tazawa, the Marlins' sixth pitcher, stranded the potential go-ahead run at third base by getting Conor Gillaspie to pop out and Denard Span to fly out to end the inning.
The game-tying single by Gomez was his first major league hit.
"I'm happy for him," Giants starter Johnny Cueto said of the rookie. "It was an important hit and allowed me to get the no-decision. I hope the best for him."
The Marlins had used a four-run seventh inning to take a 7-3 lead against Cueto and the San Francisco bullpen.
Justin Bour's two-run, tiebreaking single off Giants left-hander Steven Okert was the uprising's big blow.
Cueto was charged with six runs and six hits in six innings. He walked six and struck out two.
The Giants closed within 7-4 in the bottom of the seventh on an RBI double by Span, setting up the game-tying rally in the eighth.
Stanton had three hits and Yelich and Bour two apiece for the Marlins, whose 13 hits extended their run of games with 10 or more hits to seven.
Both teams used home runs to take early leads.
Crawford followed a Belt double with a two-run shot, his eighth homer of the season, in the second inning against Marlins starter Jose Urena to open the scoring.
Miami drew even in the third against Cueto on consecutive run-scoring doubles by Yelich and Marcell Ozuna, then went up 3-2 in the fifth on a solo homer by Stanton.
Hundley's fourth homer, a solo shot leading off the fifth inning, created a 3-3 tie.
Urena was pulled after the fifth, having allowed three runs and five hits. He walked one and struck out three.
NOTES: The Marlins go into the All-Star break at 41-46, 5 1/2 games worse than last year's mark. The Giants' 34-56 record is 23 games off last year's pace. ... Marlins LF Marcell Ozuna's RBI in the third inning was his 16th on the club's 10-game trip, tying a franchise record set by OF Gary Sheffield in 1995 and equaled by OF Cody Ross in 2008. ... Marlins OF Ichiro Suzuki flied out as a pinch hitter in the sixth inning. He went hitless in the series (0-for-1 with a sacrifice) and remained one hit behind LF Rickey Henderson (3,055) for 23rd place on the all-time list. ... Giants LHP Madison Bumgarner (separated left shoulder) is scheduled to make a fourth rehab start for Class A San Jose on Monday night. He has been tentatively penciled in to return to the Giants' rotation Saturday at San Diego. ... Upon further review, Giants LF Austin Slater (torn abductor) sustained a more serious injury than originally diagnosed in Friday's series opener. He won't have surgery, but it is possible he will miss the rest of the season.