SAN FRANCISCO — It will go down as one of the odder offensive outbursts of the season.

The Giants earned a 9-5 victory over the Boston Red Sox on Sunday at Oracle Park to secure a series win, with the offensive outburst representing the most runs they’ve scored in one game since a 10-7 triumph over the Colorado Rockies on June 11.

The Giants played big ball, manufacturing three runs on solo homers by Casey Schmitt, Mike Yastrzemski and Willy Adames. They also played small ball, executing the squeeze play late in the ballgame.

But in a game that featured four lead changes, most of their runs were the product of bad ball. Of the Giants’ nine runs, five were directly the product of two Red Sox errors.

With those opportunities, the Giants (44-34) didn’t fail to capitalize.

“When given extra outs, especially here at home late in games, we’ve been able to take advantage of that,” Giants manager Bob Melvin said.

Heliot Ramos, in particular, cashed in following both of Boston’s errors and drove in four runs.

In the third, Ramos scored two with a single after Boston’s Nate Eaton and Jarren Duran collided while trying to field a shallow fly ball. In the seventh, Ramos drove in two more runs with an opposite-field double after Red Sox second baseman Romy Gonzalez missed a line drive off the bat of Yastrzemski that allowed the Giants to take the lead for good.

Before Ramos’ run-scoring hits he, too, committed an error that led directly to a run.

In the top of the first, Duran hit a two-out line drive to left field with a runner on third base. Ramos easily tracked down the ball but muffed the catch, allowing a run to score and gifting the Red Sox a 1-0 lead. Following the error, starter Robbie Ray had to throw six more pitches to complete the inning.

“He came up to me and said, ‘It’s my bad,’” said Ray, who allowed four runs (three earned) over five innings. “In that situation, I don’t want him thinking about it the whole game. ... He was able to put it behind him and have some really good at-bats.”

Added Yastrzemski: “I had a little talk with him afterwards. I could see he was frustrated. I’ve been there. I’ve missed balls. I’ve done just about everything poorly in this game that you could do. I knew what he was feeling. I just told him, ‘It’s a physical thing. It’s going to happen. Don’t let it affect the rest of your game. You’re going to have a lot more opportunities to impact this game. He snapped out of it really quick and turned it around.’”

Ramos, indeed, had his opportunities to impact the game.

So did Yastrzemski, whose solo home run in the fifth inning was his first home run since April 30.

So did Adames, who is now batting .295 with four home runs and seven RBIs over his past 12 games.

So did Schmitt, who went 4 for 4 with his own solo homer in the fifth, a 111.6-mph line drive that matched the hardest-hit ball of his career.

While Adames and Yastrzemski have been starters since Opening Day, Schmitt only recently joined the starting lineup after Matt Chapman hit the injured list due to a hand injury.

Schmitt has made the most out of the opportunity, going 17 for 41 with four home runs and 12 RBIs since stepping in for Chapman. He’s doing all this while playing on a slightly compromised left ankle after fouling a ball off himself June 15 in Los Angeles.

With Tyler Fitzgerald continuing to struggle — Fitzgerald laid down a bunt to score a run on Sunday — Schmitt could potentially become San Francisco’s starting second baseman once Chapman returns.

“He’s playing great. I think he’s really coming into his own,” Yastrzemski said of Schmitt. “I think he needed a little bit of maybe pressure applied to him in terms of a little extra motivation. Sometimes, when you get your back pushed against the wall, you come out swinging. That’s what he’s done.

“I don’t think he’s tried to fill (Chapman’s) role, and I don’t think anyone has expected him to. ... He’s played through some stuff. He fouled those balls off his shin. He wasn’t feeling great. He’s been really gritty and he’s taken some really good at-bats. So, it’s been huge to have that production from him, and to see him with that confidence is awesome.”

Chapman out of splint

Chapman, who was placed on the injured list on June 10 (retroactive to June 9), is no longer wearing a splint on his right hand and said he could potentially begin light swinging on Tuesday.

“Whatever he tells you, back it up a few days because he’s typically a little ahead of schedule in his mind,” Melvin said pregame.

Melvin said Chapman, who has 12 home runs with a .812 OPS, is currently doing one-handed swinging in the batting cage.

Devers nursing groin ailment

Melvin said prior to Sunday’s game that Rafael Devers is currently managing a minor groin ailment. It’s not affecting his hitting but it has slightly delayed his timetable as he tries to learn first base, a position he has never played in the majors or minors.