Daniel Castro and the sinking sun had seemingly assured the Braves would avoid something that no Braves team had done in at least a century of play in their Boston, Milwaukee or Atlanta incarnations.

Castro gave the Braves the lead with his eighth-inning single and two more runs scored when Adonis Garcia’s hit a fly ball that got lost in the sun to push the lead to 7-4 in the eighth inning Sunday at Turner Field. The Braves would avoid posting the first 12-game home skid since at least 1914.

Not so fast, hopeful Braves fan.

A mere three-run lead is never safe with this beleaguered bullpen, a fact reiterated yet again by Daniel Murphy’s game-tying three-run homer with two out in the ninth inning off rookie Ryan Kelly.

The Mets rallied to tie, then won 10-7 with three two-out runs in the 10th, the first scoring on an error by third baseman Hector Olivera and the next two on bases-loaded walks by relievers Edwin Jackson and Danny Burawa. It was the Mets’ first four-game sweep in Atlanta since 1985.

“I made a bad pitch and paid for it,” Kelly said. “It was a cutter away, a back-door cutter, and it just ran back across the middle of the plate. You make mistakes to big-league hitters, you pay for it.”

The bullpen turned a three-run lead into a three-run loss in a span of two innings and in each inning, the Mets scored three runs after having two outs with no one on base.

The Braves have lost 24 of 27 games and their 12-game home skid is the longest in franchise history, at least since accurate records were first kept in 1914. The Braves fell into a last-place tie with Philadelphia at 56-88, worst records in the majors.

“(The Mets) have got a good club,” said manager Fredi Gonzalez, whose Braves fell to 26 1/2 games behind the first-place Mets, the farthest back the Braves have been since finishing the 1990 season 26 games back in the NL West. “You give them an opportunity, you open the door for them and they’ll kick it in.”

The go-ahead run scored in the 10th when Olivera’s throw to second base on a two-out fielder’s choice grounder pulled second baseman Castro off the base, allowing the runner to score from third.

The Mets had runners on the corners when Jackson issued a two-out walk and Ruben Tejada singled. After the go-ahead run scored, Jackson walked the next two batters and was replaced by Burawa, who made it three consecutive walks and pushed the lead to three runs.

Peter Moylan struck out the first two batters in the ninth, before Juan Lagares hit a double that came out of center fielder Cameron Maybin’s glove on a diving catch attempt in right-center. Maybin entered as a pinch-runner in the eighth inning, his first action in eight days after being sidelined by a corneal abrasion.

“He was an inch away from making one of the best catches I’ve seen in my life,” Moylan said. “It’s frustrating, because I know if I make a better pitch to Lagares, then everybody’s looking up their Fantasy Football scores right now instead of the way it is. But we learn from our mistakes, I guess.”

Gonzalez doesn’t want to use the sidearmer Moylan against left-handed hitters and replaced him with Kelly, who walked Curtis Granderson before Murphy’s towering home run on an 0-1 pitch. Lefty Andrew McKirahan was being rested after pitching the past two days and lefty Ross Detwiler strained a hamstring Thursday.

“It’s easy to look back now and say I should have stayed in or whatever,” said Moylan, who has given up two hits including a homer in three at-bats vs. lefties since being called up from Triple-A. “That’s certainly not the move that I would have made, but the numbers would say that (left-handers against Moylan) have a little easier time than right-handers do.”

Lefties hit .417 (16-for-34) against Moylan during his injury-shortened 2011-2013 seasons, and he didn’t pitch in 2014 while recovering from a second Tommy John elbow surgery.

“Petey did his job,” Gonzalez said. “His job is to get right-handed hitters out. He almost got the third one out; Mabes (Maybin) did a terrific job trying to get that guy. And then after that we walked a couple of people and it’s just….”

Braves rookie starter Ryan Weber, in his second major league game, gave up five hits, four runs and two walks with two strikeouts in 6 1/3 innings. The last two runs charged to him scored when rookie lefty Matt Marksberry entered with runners on the corners in the seventh inning, hit the first batter he faced, then gave up a two-run single to Granderson.

In the 20th game of his career, Castro again showed he might be more than just a future backup middle infielder. He got another start at second base Sunday and had three hits and scored three runs. He’s hit .302, including .341 (14-for-41) in 10 starts since Aug. 2.

The Mets took a 2-0 lead in the second on Michael Conforto’s homer, after a leadoff single by former Brave Juan Uribe.

The Braves answered with two runs in the third, taking advantage of a couple of defensive miscues by first baseman Lucas Duda. With runners on the corners and one out, Duda missed Adonis Garcia’s foul pop-up near the Braves dugout. His at-bat extended, Garcia capitalized on the miscue by hitting an RBI single to cut the lead to 2-1. Andrelton Simmons hit a two-out single to tie, and Simmons singled in the sixth and scored on Michael Bourn’s sacrifice fly for a 3-2 lead.