MIAMI  — Milwaukee slugger Jesus Aguilar was added to the NL All-Star team Wednesday night and then validated the selection with three hits and three RBIs, but the Brewers went 3 for 16 with runners in scoring position and lost 5-4 to the Miami Marlins in 12 innings.

Starlin Castro singled home the winning run with one out in the 12th.

Aguilar learned he won the online vote for the final NL roster spot, and he’ll also compete in the Home Run Derby next week in Washington. He doubled home a run in the first, singled in the fourth and hit a tying, two-run double in the eighth against Drew Steckenrider.

Aguilar came into the game leading the NL in homers, slugging and OPS. He has 67 RBIs and is batting .307.

Miami’s Garrett Cooper led off the 12th with a single against Jorge Lopez (0-1) and went to second on a groundout. Castro then grounded a single to left field and Christian Yelich’s throw home was off line, allowing Cooper to score standing up.

Miami took two of three in the series from the NL Central leaders.

The Marlins, who have the NL’s worst record, hit a new attendance low. The crowd of 5,265 was the smallest in the seven-season history of Marlins Park, and a few hundred fans remained at the finish.

The marathon wasn’t what the Brewers needed as they near the end of a stretch in which they play 20 days in a row, including a doubleheader Saturday at Pittsburgh.

Miami starter Dan Straily allowed one earned run in six innings, matched his season high with seven strikeouts and got his first RBI of the season with a bases-loaded walk. Justin Bour hit his 15th homer.

With the score 4-all, Miami reliever Kyle Barraclough walked the bases loaded in the ninth, but Yelich struck out on a pitch in the dirt to end the threat.

Elieser Hernandez (1-5) pitched two scoreless innings.

Milwaukee rookie Freddy Peralta lasted only 3 2/​3 innings in his shortest outing this year and allowed three runs.

The Marlins trailed 2-0 before Brian Anderson led off the fourth with a triple for their first hit. Castro hit a sacrifice fly and Bour homered. With two outs, four consecutive Marlins reached base to end Peralta’s night.

UP NEXT

Brewers: LHP Wade Miley (1-0, 1.42 ERA), who has been sidelined with a strained right oblique, is expected to be activated to start Thursday at Pittsburgh. It will be his first outing since May 8 and only his third this year.

Marlins: After a day off, the Marlins begin a three-game series at home against the Phillies, with LHP Wei-Yin Chen (2-6, 6.14) scheduled to start Friday.