MIAMI (AP)Brian Anderson atoned for a costly error with a two-run triple in the 11th inning and the Miami Marlins beat the Pittsburgh Pirates 3-2 Thursday.

Anderson originally was ruled to have been hit by a pitch from Wil Crowe (3-6), but the Pirates successfully challenged, saying it hit his bat first. Anderson then sent a drive to deep right center that scored Jesus Aguilar and Avisail Garcia.

”At any point, you don’t shut it down,” Anderson said. ”When I got hit by the pitch, I was ready to go on base. I just tried to focus on what’s in front of me. I was just thankful to have an opportunity to come up there and try to put barrel on the ball.”

Joey Wendle doubled, singled and walked for the Marlins, who had their second straight walk-off against Pittsburgh and split the four-game series.

”Hanging in there, that’s what we’ve been talking about and keep fighting until the (All-Star) break,” Miami manager Don Mattingly said.

Ben Gamel’s RBI double against Richard Bleier (2-1) in the top of the 11th put the Pirates ahead 2-1.

Pittsburgh tied it at 1 in the eighth on third baseman Anderson’s fielding error that scored Yoshi Tsutsugo from first. Tsutsugo reached on a two-out single against reliever Steven Okert. Anderson muffed Diego Castillo’s hard grounder and Tsutsugo raced home as the ball went into foul ground in left field.

”I definitely pride myself on my defense, so that’s something I have to keep working on and keep getting better at,” Anderson said.

Wendle broke a scoreless tie with an RBI double in the fifth. He was not in the original lineup but entered after Jon Berti left with an injury.

Billy Hamilton hit a two-out single and scored from first on Wendle’s line drive to right. Hamilton originally was called out on second baseman Kevin Newman’s relay throw to the plate, but a video review overturned the play.

Marlins starter Braxton Garrett struck out a career-high 11 in six scoreless innings. Garrett allowed two hits, walked two and hit two batters.

”It feels awesome,” Garrett said of his outing. ”Got ahead often and stayed in the zone like I have been recently. My slider was just a little sharper tonight than it has been the last couple of starts so I threw more punch-outs.”

Facing his former team for the first time, Zach Thompson limited the Marlins to one run and four hits in 6 2/3 innings. Thompson, who joined the Pirates in an offseason trade for catcher Jacob Stallings, walked three and struck out two.

”I think once I got past the second inning, I started calming down and kind of threw like I’m used to,” Thompson said.

Berti, the majors’ stolen base leader, exited after the first because of a mild left groin strain. He drew a leadoff walk, but felt discomfort after stealing second – his 28th stolen base this season.

Marlins shortstop Miguel Rojas left in the ninth after he was hit in the mouth by the helmet of Oneil Cruz, who was unsuccessful on a steal attempt of second.

NOT THE TYPICAL INFIELD

The injuries to Berti and Rojas resulted in a radically different infield late for Miami. First baseman Aguilar finished at third and Anderson moved from third to second. Wendle replaced Berti at second early before shifting to shortstop. NL All-Star Garrett Cooper, who was expected to rest another day because of knee soreness, replaced Aguilar at first.

”It’s one of those games where you’re glad there’s a DH,” Mattingly said. ”There’s a lot of stuff going on, like Aguilar playing third and he did that well and Anderson at second. It was a nice little team effort from them and the bullpen.”

CIRCUITOUS PATH

Pirates right fielder Castillo took a different angle as he tracked Nick Fortes’ drive in the second. Castillo turned right before abruptly turning and diving to his left to catch the shot on the warning track.

TRAINER’S ROOM

Pirates: C Henry Davis (left wrist injury), the No. 1 overall selection in last year’s draft, will be shut down for the remainder of the month.

Marlins: RHP Cole Sulser (right lat strain) is continuing with his throwing program.

UP NEXT

Pirates: LHP Jose Quintana (2-4, 3.59 will start the opener of a three-game series Friday at Colorado. Quintana will face RHP German Marquez (5-7, 5.66).

Marlins: RHP Sandy Alcantara (9-3, 1.73) starts the opener of a home series against Philadelphia Friday. RHP Kyle Gibson (4-3, 4.53) will start for the Phillies.

More AP MLB: https://apnews.com/hub/mlb and https://twitter.com/AP-Sports