SAN DIEGO – After rallying in the first two games of the series, the San Diego Padres couldn’t do it for a third day in a row as they lost 10-8 to the Miami Marlins on Wednesday afternoon at Petco Park.

In a game that had a pair of early ties and five lead changes overall, the Padres (31-23) allowed a pair of unearned runs as part of the three run eighth by the Marlins (22-32). Augustín Ramírez delivered a two out, two-RBI single and Eric Wagaman had a one-RBI knock to bring home the decisive runs, as Ramírez finished 4-for-5 with 4 RBIs and a home run.

With the Padres holding an 8-7 lead, the eighth began when Jason Adam, who took his first loss of the season, missed high with a changeup and hit Connor Norby in the head with a changeup.

Then Manny Machado lost the ball on the transfer when Nick Fortes chopped a fielder’s choice to third. Wandy Peralta came on to face Jesús Sánchez and got a grounder to short for a fielder’s choice at second, but Miami’s fleet-footed right fielder beat out the double play attempt and then Victor Mesa Jr. drew a two out walk to set the table.

Adam finished having allowed three hits and a pair of unearned runs in 2/3 of an inning pitched, and also had a wild pitch that allowed Miami’s lone run in the seventh after Yuki Matsui allowed a lead off double to Victor Sanjoa.

The bullpen allowed all five of Miami’s inherited runners to score, a season high, as the unit stretched with a pair of 11 inning games as well as a bullpen game over the recent nine day stretch of play couldn’t seal the result. Eight of the ten Marlins runs came with two outs.

Gavin Sheets drove in three runs to extend his team lead to 34 RBIs — 21 in May — and gave San Diego an 8-7 lead when he hit his 11th home run of the season in the seventh inning.

The Padres also had leads of 1-0 after the second and 6-1 after the fourth, but each time Miami had an equal answer the following half.

The Padres opened the scoring in the second inning when Jackson Merrill smacked a double down the right field line and advanced to third on an error. Sheets brought him home by reaching to poke a high and away fastball outside the zone down the third base liney.

It could’ve been more as Xander Bogaerts reached on a fielder’s choice and stole second, then Jake Cronenworth walked before an inning-ending double play liner. The stolen base, and a fourth inning steal by Fernando Tatis Jr., gave the Padre five over the last six games after having gone through a 12-game stretch with only 3 swiped bags.

Then Ramírez had a game-tying solo home run to left field in the third inning off starter Kyle Hart.

San Diego was patient against Marlins starter Sandy Alcantara in the fourth inning, as the Padres batted around by working three walks to go with four hits.

Cronenworth had a two-RBI double, Elias Díaz laced an RBI single, Luis Arraez had an RBI sacrifice fly and Machado had an RBI single. But the inning ended when, on the Machado hit, Tatis was thrown out at home to end the inning after running through a stop sign.

Alcantara lasted four innings as the Padres touched him up for seven hits, six runs and drew four walks with no strikeouts.

The Marlins answered with five runs in fifth, chasing starter Hart after he allowed his second solo home run of the day — this one off the bat of Sánchez. The Marlins added another RBI single from Ramírez, then after back to back hits by Ramírez and Wagaman, Hart gave way to David Morgan, who gave up a three-run home run to Otto Lopez.

Hart lasted 4 2/3 innings as he allowed six hits and five runs, with the strike out and pair of home runs.

Reliever Ronny Henriquez pitched the seventh and eighth to earn his third win of the season and Calvin Faucher picked up his third save for the Marlins.

Hart, making his first MLB start since April 23, was recalled from Triple A El Paso on Wednesday morning. Pitcher Omar Cruz was optioned to the Chihuahuas to complete the roster move.

After an off day on Thursday, the Padres will open a three game set against the Pittsburgh Pirates, who completed a series win against Arizona and have won six of their last 10 games. San Diego swept the previous series at PNC Park May 2 through 4.

Nick Pivetta (5-2, 2.72 ERA) will take the ball for the Padres, while Mitch Keller (1-6, 3.66 ERA) is the anticipated starter for the Pirates for the 6:40 p.m. first pitch at Petco Park.

This story will be updated.