The Pirates couldn’t do much against starting pitcher Julio Teheran on Saturday, and the Braves did just enough against Jeff Locke for a two-run lead.

Everything was going smoothly for the Braves but the specter of the struggling bullpen hung over the outcome. The bullpen burned the Braves again when relief pitcher Jim Johnson blew the lead in the eighth inning, but then catcher Christian Bethancourt made that moot with a walk-off homer in the bottom of the ninth for a 5-4 victory at Turner Field.

Bethancourt sent Pirates reliever Vance Worley’s first pitch in the ninth deep to right field. Gregory Polanco gave chase but the ball just cleared the wall inside the foul pole for Bethancourt’s first career home run.

“That’s a moment I will never forget,” Bethancourt said. “When you was a kid, those sort of things are always in your book. Those are things you wanted to do. You want to hit your first homer and you want to hit a walk-off homer. I got both at the same time so I’m pretty happy.”

Teheran had limited the Pirates to three hits and two runs when he gave up back-to-back singles to Francisco Cervelli and Jordy Mercer with one out in the eighth. Johnson replaced Teheran and retired Jung Ho Kang on a groundout before Gregory Polanco hit his 1-0 pitch through the middle of infield to score Cervelli and Mercer.

It was the latest setback for the Braves’ bullpen, which has the worst ERA in the majors. Braves relievers couldn’t preserve a tie and allowed six runs over the final four innings in a 10-8 loss to the Pirates on Friday. Before that the bullpen had blown leads in three of six losses on the West trip.

This time Bethancourt bailed out the bullpen and the Braves stopped their losing streak at three games.

“We were just talking earlier today, we just have to find a way to win those close games,” Braves infielder Chris Johnson said. “I feel like we’ve been on the other side of those a little bit this month so hopefully this is a start to kind of turn those games around and find a way to win.”

It was a promising start for Teheran, who has struggled for much of the season after making his first All-Star team in 2014.

Teheran was charged with four earned runs over 7 1/3 innings. He faced the minimum three batters in six of the innings while throwing 69 strikes on 103 pitches.

The Pirates had just one extra-base hit against Teheran, Andrew McCutchen’s two-run homer to tie the game in the fourth. Teheran retired the next 12 batters in a row before Cervelli and Mercer’s singles in the eighth.

“I feel like I did my job,” Teheran said. “I was battling the whole game. Just one mistake that cost me two runs and the last inning I gave up two base hits and I wanted to stay (in the game) but that’s something you can’t control.”

The Braves had scored six or more runs in each of their previous six games. They scraped out enough runs against the Pirates with home runs from Bethancourt and Chris Johnson while mixing in with some small ball.

With second baseman Jace Peterson out with a thumb injury, Braves manager Fredi Gonzalez sent out a lineup heavy with right-handers against lefty Locke. Juan Uribe moved from third to second, Chris Johnson started at third and Jonny Gomes was in left field.

Johnson started the scoring for the Braves when he homered against Locke to lead off the second. Johnson’s drive bounced off the top of the center field wall, out of McCutchen’s reach, and into the stands.

Johnson entered the game hitting .316 and slugging .445 in his career against left-handers. He’s hit safely in three of six games since returning from the disabled list after missing 23 games.

The Braves took a 2-0 lead in the third inning on Freddie Freeman’s sacrifice fly that scored Cameron Maybin. Maybin led off the inning with a single, stole second and moved to third on Andrelton Simmons’ groundout to second.

After the Pirates came back to tie it on McCutchen’s home run, the Braves used more small ball to regain the lead and extend it.

Gomes walked to lead off the fourth and then took second base with is first steal since the 2013 season. Gomes scored when Bethancourt singled to left with two outs.

Bethancourt singled again to lead off the seventh inning and moved to second on Teheran’s sacrifice. Hot-hitting Maybin scored Bethancourt with a single that gave the Braves a 4-2 lead and chased Locke.

Jim Johnson gave back that lead before Bethancourt ended the game in dramatic fashion. Bethancourt entered the game batting .179 but had three hits against the Pirates to raise his average to .205.

“He’s been pretty patient, kept working and never put his head down,” Gonzalez said. “Hopefully this carries him the rest of the year. This guy belongs in the major leagues, there’s no question. There’s no ‘ifs,’ ‘buts’ or maybes there. Maybe this game will catapult him through the rest of the summer.”