Saturday night began the same way as Friday night, with the Atlanta Braves taking an immediate lead on back-to-back home runs for the second game in a row, but there was a much happier ending the second time around.

Leading off the bottom of the ninth, Rafael Devers turned a Pierce Johnson 2-1 curveball into the first walk-off home run of his career.

It was the turnaround the Red Sox badly needed after a four-game losing streak put them below .500. It was also a welcome change after eight one-run droppings out of their last 11 losses. Their 7-6 victory over the Atlanta Braves puts them at 23-24, one game away from getting their heads above water again.

Unlike Friday night when Garrett Crochet rebounded from the two solo homers and completed seven innings, it was a short Saturday start for Lucas Giolito. The right-hander lasted just four innings, and yielded six earned runs on eight hits, including a trio of homers. Throwing 87 pitches (52 strikes), he issued two walks, struck out three, and was charged with one pitch timer violation.

It was a far cry from Giolito’s previous outing, a meticulous, deep performance of 6.2 innings of one-run ball in Kansas City.

Giolito had no problem getting the first out of an inning, but he was unable to record a second out without some damage in each of the first three frames. Austin Riley’s one-out walk precipitated Matt Olson’s two-run blast in the first, and Marcell Ozuna hit one over and past the Green Monster to extend the lead to 3-0.

The bottom of the Braves order also put two in scoring position on back-to-back one-out singles by Eli White and Nick Allen in the second, but Giolito was able to work around them.

Batting in the third, Ozuna drew a one-out walk and came home to score when catcher Drake Baldwin pelted one. Upon review, the crew chief upheld their call: fair inside the Pesky Pole for another two-run jack and a 5-0 Braves lead.

Grant Holmes had vastly different experience with the Boston bats. The Braves starter lasted six innings and though he issued four walks, he held the home team to two earned runs on three hits and struck out five men. He threw 99 pitches, 57 for strikes.

Holmes retired the first seven Sox before Carlos Narvaez pried the door open in the bottom of the third. The rookie catcher, who entered Saturday hitting .387/.457/.548 in 10 games this month, drew a one-out walk to become Boston’s first base runner, and came home to score on Jarren Duran’s two-run rocket to dead center.

For a moment, the Red Sox offense came alive. Devers followed Duran’s blast with a double, and practically skipped to second base as the ball bounced around the lower-left corner of the Green Monster, befuddling former teammate Alex Verdugo. Alex Bregman joined Devers on base with a walk.

It looked like Kristian Campbell had an RBI knock off the wall in center, even a game-tying three-run homer. Instead, Michael Harris II left up and grabbed the ball to end the inning. After that, even the Braves proffered opportunities, but the Red Sox didn’t capitalize. Three of their four base runners between the fourth and sixth innings were on walks and an error by Olson; none of them even reached third.

Against the Braves bullpen, the Boston bats turned the table at last. Ceddanne Rafaela’s leadoff double and Devers’ RBI single knocked Aaron Bummer out of the seventh inning after just one out, and Bregman greeted Enyel De Los Santos with an RBI double off the Green Monster.

The Red Sox didn’t let a Braves reliever complete the eighth inning, either. Rafael Montero recorded two outs, but Abraham Toro (double) and Narváez (single) collected a pair of one-out knocks in between, and Duran greeted Johnson with a two-run, game-tying single.

After Aroldis Chapman worked around a pair of base-runners to hold the tie, it was Devers who blasted Boston to victory.