SAN FRANCISCO – The Braves stopped Tony Bennett’s “I Left My Heart in San Francisco” from serenading Oracle Park for the third time this weekend. They defeated the Giants 3-0 on Sunday afternoon, avoiding a sweep and snapping a four-game skid, as Eddie Rosario hit for the cycle.

It’s an enormous win for the Braves, who could’ve kissed the good life of being alone atop the division goodbye with a loss and a Phillies’ victory later Sunday night. Instead, they’ll head to Arizona at least one game up in the tight National League East race.

“That’s a big win,” manager Brian Snitker said. “The last two days, what these guys went through. ... It was just good for the guys to bounce back today and get this win going into Arizona.”

The primary culprit of the Braves’ losing skid was an inability to hit with runners in scoring position. They were 4-for-26 in that category over the last three games. It appeared those woes would hurt them again Sunday before slugger Adam Duvall unleashed the team’s offensive frustrations with one crack of the bat.

Duvall smacked a slider from Giants starter Anthony DeSclafani for a two-run homer in the seventh, breaking a scoreless tie. Third baseman Austin Riley doubled in the previous at-bat, so it even counted as a hit with a runner in scoring position – their only such hit of the day.

The left fielder Rosario followed with a homer that made it 3-0. Rosario joined first baseman Freddie Freeman (Aug. 18) as the Braves to hit for the cycle this season. He completed the cycle with a single in the ninth.

“I was so happy,” Rosario said. “I’ve tried before, came close in 2017 or 2018. I don’t remember. But I had the opportunity today and I did it.”

Rosario said it’s his first cycle since doing so in the Gulf Coast League back in 2010, five years before he debuted in the majors.

The afternoon was largely a pitcher’s duel between DeSclafani and Max Fried, who was superb for the Braves. Fried had his best start since his complete-game shutout in Baltimore, allowing three hits over seven scoreless innings against the best team in MLB. Fried struck out five while walking one.

“My fastball command was really big today,” Fried said. “My curveball worked pretty well. The slider kept them off balance. I mixed in the change-up. We had a good mix of all pitches in all counts. That’s a really good lineup. They obviously have the best record in baseball and that’s not a fluke. You have to really move the ball around, change speeds. Me and (catcher) Travis (d’Arnaud) had a really good plan of attack.”

Fried has pitched 10 consecutive quality starts (at least six innings and three or fewer earned runs allowed). It’s the longest active such run in the majors. He’s the third pitcher to achieve such this season, joining aces Walker Buehler (Dodgers) and Brandon Woodruff (Brewers).

Fried entered the day with a 2.02 ERA over his last nine starts. The Braves are now 8-2 in his last 10 outings.

“He had everything working today,” Snitker said. “He was spot on, as was their guy (DeSclafani). Max is special, he’s a front-end guy. He just continues to mature and get more confidence. That was really good today. It was a great day to pitch, a beautiful day here. That’s what makes this place (Oracle Park) really cool, days like this. It was a great pitching matchup. Great pitched ballgame by both sides. I’m just glad we came out on top.”

Luke Jackson, back from the paternity list, and Will Smith kept the Giants off the board in the final two frames. It was a nice rebound showing from Smith, who blew the save in Friday’s loss.

It was a hard-fought series in which the Braves lost in extras Friday and fell short 2-0 on Saturday. But they ultimately avoided the disaster scenario of a sweep, ensuring their NL East lead won’t have evaporated by the time they’re in Phoenix.

“That’s as close to the postseason as you’re going to get,” Duvall said against the Giants.

The Braves’ 11-game western road trip continues Monday in Arizona, where they’ll begin a four-game series against the Diamondbacks. Huascar Ynoa (4-5, 3.26) will start the opener.