The Braves beat Miami seven times in nine games before Friday, but their best pitcher had lost his only start this season against the Marlins, and it looked like Julio Teheran would lose to them again Friday after blowing a late-innings lead.

Tyler Flowers prevented Teheran from getting the loss when the catcher hit a line-drive, game-tying homer in the ninth inning, but he couldn’t prevent the Braves from losing — and in rather improbable fashion.

Marlins ace Jose Fernandez came in to pinch-hit in the 12th inning and drove a two-run, two-out double to the left-center field fence off Casey Kelly, lifting Miami to a 7-5 win at Turner Field.

“He can swing the bat,” Braves interim manager Brian Snitker said of Fernandez, who is 7-for-28 with two doubles and five RBIs. “Before that inning started I was trying to look over in their dugout. I was hoping maybe they had sent him back (to the hotel to rest) for tomorrow. It didn’t surprise me when he came out.”

Actually, Marlins manager Don Mattingly had suggested Fernandez go back to the hotel to rest as the game wore on, but the pitcher said he preferred to stay with the team just in case he was needed.

Teheran was charged with 11 hits and five runs in 6 2/3 innings, the first time he allowed more than three runs since giving up six April 14 at Washington in his third start. He gave up two homers and three runs in the first inning.

Beaten by Fernandez's bat Friday, the Braves face him in his conventional role Saturday afternoon when the big right-hander goes to the mound with a 10-3 record and 2.28 ERA. The Braves will counter with journeyman Lucas Harrell, 31, coming from Triple-A to make his first major league appearance since 2014.

Braves center fielder Ender Inciarte left the game with a right groin strain and is listed as day to day. He got up gingerly after stealing second base in the fifth inning and came out of the game after the inning, but Snitker said it was more precautionary and that he thought Inciarte might return to the lineup as soon as Sunday.

Flowers, the catcher who had three doubles and a ninth-inning ejection in Thursday’s series-opening comeback win, put the Braves in position to pull off another comeback win Friday with his sixth homer and third in nine games. But the Braves couldn’t convert several late-innings scoring opportunities.

“It was eventful,” Flowers said. “Julio wasn’t real sharp early on, but he was able to settle in and go a lot deeper in the game that probably most people expected him to…. There were a lot of positives to take away from it. We just couldn’t come up with the big hit at the end. They got one more.”

In the 10th inning, Freddie Freeman reached second base when he led off with a high fly to shallow left field, which bounced off left fielder Christian Yelich’s glove as shortstop Adeiny Hechavarria nearly ran into him. But the Braves left the bases loaded that inning, after failing to score in the ninth when they got a runner to third base with one out.

Flowers also gave the Braves a scare in the 10th when he got hit by a pitch that caromed off his hand and the side of his head, knocking off his helmet and protective glasses that he plays in. But he stayed in the game, going to first base to load the bases with two outs before Eric Aybar flied out to end the inning.

The Braves also stranded a runner at third in the ninth after Aybar singled, advanced on a sacrifice and went to third with one out on a wild pitch. Jace Peterson struck out and Chase d’Arnaud lined out..

Teheran gave up three runs in the first inning on three extra-base hits within the first four batters, including a leadoff homer by Derek Dietrich and a two-run homer by Marcell Ozuna after Teheran got ahead in the count 0-2 on two sliders. He threw him two more sliders, one for a ball and one for a homer.

“First two strikes were really good pitches,” Teheran said. “When you try to throw a better one, that’s when you start missing. I should’ve just threw it like I did the first two.”

The Braves answered with two runs in the second inning and took a 4-3 lead in the fifth on d’Arnaud’s first major league home run, a two-run shot. But Teheran gave up the lead in the seventh, when he struck out the first two batters before allowing a Martin Prado single and a tying double by Christian Yelich.

The go-ahead run scored after Teheran left and Ozuna greeted reliever Chris Withrow with a broken-bat single to center.

Teheran had a 1.61 ERA and .160 opponents’ average in his past 12 starts before Friday, and hadn’t allowed double-digit hits in more than a year, since giving up 13 in 6 1/3 innings at Boston on June 16, 2015.

He remains winless in 10 home starts this season, despite 60 strikeouts with 16 walks in 61 1/3 innings.

“He wasn’t as sharp as he had been,” Snitker daid, “but I don’t know that it’s fair to expect somebody to, well, good Lord, we’re all human, so he’s going to have a hiccup every now and then and not just be lights-out and one-hit shutout.”

D’Arnaud homered for the first time in 327 career plate appearances spread over five major league seasons with three teams, including 151 PAs as a Pirates rookie in 2011. He homered in his single-season career-high 152nd PA for Atlanta.

Peterson extended his career-best hitting streak to 12 games with a seventh-inning double in his first at-bat after entering the game when Inciarte exited.