Denis Poroy-Imagn Images

Agustin Ramirez capped a four-hit, four-RBI performance with a go-ahead, two-run single in the eighth inning, helping the visiting Miami Marlins to a 10-8 victory over the San Diego Padres on Wednesday.

Ramirez belted a solo homer in the third inning and added an RBI single as part of a five-run fifth inning.

Miami's Otto Lopez launched a three-run homer among his three hits and Jesus Sanchez had a solo shot.

Eric Wagaman had an RBI double and Javier Sanoja scored on a wild pitch for the Marlins, who overcame an early five-run deficit to salvage the finale of this three-game series.

Gavin Sheets belted a two-run homer to give San Diego an 8-7 lead in the seventh inning before the Marlins reached Jason Adam (5-1) in the eighth and prompted a mound visit for Wandy Peralta. The Padres elected to keep Peralta in the game, and Ramirez made them pay for that decision by ripping a single to center field to plate two runs and give Miami the advantage.

Wagaman's double extended the lead to 10-8 and made a winner out of Ronny Henriquez (3-1), who served up Sheets' homer. Henriquez allowed two runs on one hit in two innings to pick up the win, and Calvin Faucher retired the side in the ninth to secure his third save of the season.

Adam, who uncorked a run-scoring wild pitch in the seventh, allowed two runs on three hits in two-thirds of an inning.

Jake Cronenworth ripped a two-run double and Sheets, Elias Diaz and Manny Machado each had an RBI single for the Padres, who saw their three-game winning streak come to a halt

Cronenworth's two-run double down the first base line gave San Diego a 3-1 lead in the fourth inning. The Padres weren't done, however, as Diaz and Machado sandwiched RBI singles around Luis Arraez's sacrifice fly as part of a five-run frame.

Miami, however, responded with a five-run inning in the fifth, with Sanchez belting a solo shot and Ramirez adding an RBI single. David Morgan replaced Kyle Hart and saw Lopez deposit his 0-1 fastball over the wall in left-center field for a three-run homer to forge a 6-6 tie.

Sheets' RBI single off Sandy Alcantara opened the scoring in the second inning before Ramirez leveled the contest in the third after belting a first-pitch fastball from Hart.

More must-reads:

TODAY'S BEST
Knicks-Pacers takeaways: Indiana punches ticket to NBA Finals with dominant win
Jonathan Toews open to joining Maple Leafs as part of comeback
Paris Saint-Germain beats Inter Milan to earn record-setting Champions League title
Pelissero: Steelers were never informed by Aaron Rodgers on his arrival
Astros offer troubling injury update on slugger Yordan Alvarez
Cardinals place surging OF on 10-day IL
13-year MLB veteran announces retirement 
Dodgers' Mookie Betts suffers toe injury, hoping to avoid IL
Aaron Judge, Shohei Ohtani set MLB record in first inning of Yankees-Dodgers clash
Chicago Bears' Caleb Williams dealt concerning message from ex-GM
49ers' Christian McCaffrey draws major concern after first practice
Eagles to trade player year after signing him to record contract
Jets OC shares how Justin Fields has already been 'absolutely phenomenal'
Paige Bueckers sidelined after entering WNBA's concussion protocol 
Boston radio host shares bombshell report about Stefon Diggs
NFL's active leader in games played wants to return for historic 20th season
Yankees predicted to add unexpected 21-year-old DJ LeMahieu replacement
Steelers could add former third-round pick in new trade offer
Blue Jays place struggling star OF on injured list
SS Willy Adames is 'a dude,' but he's not producing for Giants