Cameron Maybin was thrown out on a daring decision to try to score from third on a fly-ball foul to left in the eighth inning, but the Braves center fielder more than made up for it before the day was through.

Maybin and Freddie Freeman delivered two-out RBI singles in the ninth inning to force extra innings, and Maybin’s two-run single in the 11th lifted the Braves to a 5-3 win against at Citi Field.

“Guys battled their butts off,” said Braves shortstop Andrelton Simmons, who had four hits, including a leadoff single in the 11th. “That’s fun about this team — we make a lot of contact and we stay in games. … We’ve been battling to stay in games. Some of them, like (Friday) night, it didn’t work out. But we’re giving ourselves a chance. That’s all you can do.”

The Braves (30-32) pulled to within 2 1/2 games of the Nationa League East-leading Mets and snapped a five-game losing skid against them.

“It’s just fun to win, man,” said Maybin, whose latest three-hit (and three-RBI) game raised his average to .303. “Especially against these guys. They’ve been playing well against us. We felt like we let them off the hook a few times this year. Shelby (Miller) went out and competed his butt off, and our bullpen did a great job keeping us in the game.”

The Braves, after using top relievers Jim Johnson and closer Jason Grilli in the ninth and 10th innings, and wanting to rest relievers David Aardsma and Brandon Cunniff, turned to rookie starter Williams Perez in the 11th.

Perez has struggled in the first inning of some starts and gave up consecutive singles to begin the 11th. But then he got John Mayberry Jr. to line into a double play and induced a Juan Lagares ground out to end the game.

Braves manager Fredi Gonzalez said Perez, who threw only nine pitches, was still in line to start Monday, but left open the possibility of pushing back that start and having someone replace him, if necessary.

Freeman’s two-out homer off Mets ace Jacob deGrom in the first inning was the first homer that deGrom had allowed in nearly a year at Citi Field and accounted for the only offense by either team for six innings. But that wasn’t even the biggest two-out hit of the day for the Braves first baseman.

Freeman’s single in the ninth off left-hander Alex Torres tied the score 3-3 and quieted a previously boisterous crowd.

“We expect him to,” Simmons said of Freeman’s big hits. “It’s almost expected of him to come through now.”

The pair of two-out, run-scoring hits by Maybin and Freeman came after the Mets scored three in the seventh for a 3-1 lead.

Freeman’s homer off deGrom was the first he’d allowed in 16 home starts, dating to last season, and for most of the game Saturday it seemed it might be enough offense for the Braves and their ace, Miller.

But Miller’s five-hit shutout evaporated in the seventh, when three of the four batters he faced collected hits, including Travis d’Arnaud’s two-run single that chased Miller from the game. The third run charged to him scored when reliever Dana Eveland allowed a wild pitch and RBI double to the only batter he faced, Lucas Duda.

Miller was charged with eight hits, three runs and two walks with four strikeouts in 6 1/3 innings. He got no decision and is 0-1 in his past five starts despite a 3.23 ERA in that span. The Braves scored a total of seven runs while he was in those.

“We got a win, that’s all that matters,” Miller said. “Our offense battled so hard in the top of the ninth to get those runs and get us back in the game. Kudos to them for doing that. Bullpen came in after that and shut it down, which is awesome.”

DeGrom gave up five hits, one run and one walk with nine strikeouts in seven innings, but got no decision to remain 4-0 with a 1.25 ERA in his past six starts, with 59 strikeouts and six walks in 54 innings.

“DeGrom was nasty, and Shelby was, as well,” Gonzalez said. “It was a 3-1 game, and we didn’t give up. We battled and battled. I think both teams were on fumes in the bullpens, and we were able to convert. Cameron Maybin was terrific at the plate. Got three RBIs, two RBIs in extra innings to be able to win us the game. And using Williams (Perez) there — we didn’t know how he was going to react, but we didn’t have any other option but to go to him, and he did a nice job.”

The Braves, as they are wont to do, scratched and clawed to get back in the game in the late innings.

Trailing 3-1 in the eighth, Maybin hit a leadoff double, made a daring steal of third base after what Gonzalez said was a missed sign, then made a risky attempt to score on Freeman’s foul-ball fly out to medium-range left field. Left fielder Darrell Ceciliani caught it just over the line, coming forward in good position to throw, and made a strong one-bounce throw to catcher d’Arnaud, who tagged the sliding Maybin for the second out.

“I think the stolen base was just a missed sign, a miscommunication,” Gonzalez said. “I think on the shallow fly ball, him and Bo (third-base coach Bo Porter) read that the (left fielder’s) momentum was going to carry him toward the stands a little bit, and you’ve got to make guys make plays. And Maybin’s a guy that can run a little bit. He pressed the issue there a little bit, and he made a good throw and a good tag. Bang-bang.”

Nick Markakis then reached on an error and pinch-hitter Jonny Gomes singled to put runners on the corners, but A.J. Pierzynski grounded out to end the threat. Pierzynski also grounded into an inning-ending double play in the fourth inning and grounded out with two on to end the sixth inning.

The Braves went 0-for-9 with runners in scoring position Saturday before Maybin’s ninth-inning hit, after going 2-for-12 in those situations in Friday’s 5-3 loss in the series opener. But they had three hits in their final five at-bats with runners in scoring position Saturday, including two by Maybin, who ranks among the majojrs’ top three with a .468 average in those situations.

Chris Johnson started the ninth-inning rally with a leadoff walk against Hansel Robles, who was filling in on a rest day for regular closer Jeurys Familia.

Simmons followed with the third of his four singles. After pinch-hitter Juan Uribe struck out trying to check his swing, Jace Peterson hit a potential game-ending double play grounder to shortstop Wilmer Flores, who bobbled the ball and only got one out at second base, which proved crucial.

Maybin drove in a run with his single to left field, and the lefty Torres was brought in to face Freeman. He worked the count full and fouled off a pitch before hitting his game-tying single to center.