For the third consecutive outing, Braves starter Mike Foltynewicz took a shutout or lead to the sixth inning and failed to make it out of the inning.

The Pirates scored four runs in the sixth Tuesday night to turn a one-run deficit to a three-run lead en route to a 5-3 win against the Braves in a series opener at Turner Field.

“First couple of innings probably was the best I’ve felt all year, the most confident I’ve felt all year,” said Foltynewicz, who didn’t allow a hit until the fifth. “Just the last four or five outings it’s been one big inning that’s hurt me.”

He a 2-1 lead entering the sixth, when Foltynewicz walked leadoff hitter John Jaso. Second baseman Jace Peterson dropped a ground ball to turn a would-be double play into one out at first base, and the next three batters peppered Foltynewicz with an RBI single, another single and a two-run double by Jung Ho Kang.

Interim manager Brian Snitker replaced Foltynewicz at that point, his pitch count at 103 including 70 strikes.

The Pirates had a 3-2 lead and still had two on base. Both scored one out later when Adam Frazier doubled against reliever Jose Ramirez. Those runs were tacked onto the ledger of Foltynewicz, charged with four hits, five runs and three walks in 5 1/3 innings.

“The big thing for a lot of these young guys is getting through that sixth inning,” Snitker said. “That third time around the order. He was throwing the ball really well. It’s just about learning to get through the sixth inning, pretty much.”

Nick Markakis drove in two runs for the Braves with a single and a leadoff home run in the eighth inning, his sixth homer. But Braves hitters were 2-for-12 with runners in scoring position, including 0-for-7 in those situations by Nos. 3-4 hitters Freddie Freeman and Matt Kemp in his first game since being traded to the Braves.

Freeman’s 0-for-5 game included 0-for-4 with three strikeouts with runners in scoring position, and Kemp went 0-for-4 including 0-for-3 with a walk with runners in scoring position. Kemp struck out with a runner at first to end the game.

Pirates starter Gerrit Cole (7-6) allowed two runs (one earned) and seven hits in five innings and improved to 3-0 with a 1.76 ERA in four career starts against the Braves. The big right-hander has allowed one or no earned runs in seven of his past 10 starts and hasn’t given up a homer in his past eight.

“We had him on the ropes early a little bit, but he’s a good pitcher, he’s an ace,” Peterson said. “In the first couple of innings we had runners on second with two outs. That’s when he kind of rares back. He’s got an electric fastball and good out pitches.”

Foltynewicz hit catcher Francisco Cervelli in the helmet with an off-speed pitch with one out in the fifth inning, a frightening incident that forced Cervelli from the game and seemed to disrupt Foltynewicz’s focus. Adam Frazier followed with a double on a 13-pitch at-bats for the Pirates’ first hit, and Jody Mercer’s groundout tied the score, 1-1.

Atlanta reclaimed the lead in the fifth on Markakis’s two-out RBI single, after a Peterson leadoff single and Kemp walk.

But the sixth inning was Foltynewicz’s undoing. He’s 2-3 with a 5.50 ERA in his past seven starts and has failed to make it out of the sixth inning in four of those games including each of the past three.

“If I can do a better job of controlling that it’ll give my team a better chance to win,” he said. “We’ll work on that. It’s going to be alright. It’s just one inning we need to control…. It has been the sixth most of the time. I don’t know if it maybe it’s just weird luck or something like that, but yeah, it’s just one inning, about the sixth inning every time, just things start hitting the fan. Some bad breaks here and there. Nothing really to worry about, just instead of three or four innings maybe cut it down to one or two.”

Wednesday at Minnesota, the Braves staked Foltynewicz to a 7-0 lead before the Twins scored three runs in the fourth inning and two in the fifth. The Braves scored another run in the sixth to push the margin back to 8-5, but Foltynewicz gave up three hits to the first four batters of the two-run sixth inning and was replaced with one out.

He got the win in that game despite allowing a career-high 12 hits and seven runs (six earned) in 5 1/3 innings.

In Foltynewicz’s start before that, July 21 at Colorado, he pitched a one-hit shutout through five innings, then gave up a leadoff walk, a single and a Carlos Gonzalez three-run homer to start the sixth. He allowed another walk and single before he was replaced with two out in the sixth in that loss.