By The Sports Xchange

SAN FRANCISCO — San Francisco Giants rookie Mac Williamson hasn’t been around Major League Baseball long, but already he’s developed a theory.

When things aren’t going your way early in a ballgame, you will eventually get another chance to further embarrass yourself.

READ MORE: 'Stigma free zone,' National Alliance on Mental Illness brings back fundraising walk this Saturday in Boston

Such was the story of Williamson’s major league career until he responded to two earlier strikeouts with a tie-breaking home run on David Price’s first pitch of the eighth inning Wednesday night, lifting the San Francisco Giants to a 2-1 victory over the Boston Red Sox and a split of the two-game interleague series.

“I’ve been working on staying positive,” Williamson said of a career that had featured more strikeouts (16) than hits (10) before he teed off on Price. “This game can humble you.”

The Giants’ Brandon Belt and Red Sox’s Chris Young also hit solo homers to account for all the scoring in a pitchers’ duel between Price and San Francisco’s Madison Bumgarner before Williamson’s difference-making blast.

Bumgarner left the game after six innings of one-run ball, having thrown 101 pitches. He did not get a decision.

“It’s always the pitching,” Giants manager Bruce Bochy said of the key to ending a three-game losing streak. “Getting a couple of home runs helps.”

The win was the Giants’ 19th in 26 games since May 11, the most in baseball, and came on the heels of a 5-3, 10-inning defeat in the series opener.

Right-hander Cory Gearrin (2-0), the third Giants pitcher, got the win after pitching a 1-2-3 top of the eighth.

Hunter Strickland threw one pitch in the last of the ninth, retiring pinch hitter Marco Hernandez on a ground ball to get out of a two-on, two-out jam, to record his first save.

Williamson, San Francisco’s left fielder, dropped Hanley Ramirez’s inning-opening fly ball off Santiago Casilla for a two-base error to give Boston life in the top of the ninth.

Casilla then struck out Jackie Bradley Jr., and left-hander Javier Lopez, after walking pinch hitter David Ortiz, fanned Travis Shaw, setting the stage for Strickland.

“All night long, the wind was blowing from right field to left field,” noted Williamson, who claimed Ramirez’s high fly darted away from him. “I’m thankful Casilla got the strikeout. Then Javy and Strickland picked me up big-time.”

Williamson, making just his fourth start in an injury-depleted Giants outfield, struck out in his first two at-bats against Price, dropping his season average to .150 (3-for-20).

But he insisted he’d learned from earlier late-game failures, which helped lead to two demotions already this season.

“I tried to stay positive,” he said of his approach to the eighth-inning at-bat. “You’re not having a good game, and a lot of times you’re in a tough situation later in the game. If you let the earlier at-bats affect you, you’re going to fail again. But if you stay positive, you have a better chance.”

He got a hold of a Price curveball and lifted a towering shot that bounced off the top of an advertisement that forms the outfield barrier in the left-field corner, barely eluding a leaping Young.

READ MORE: Young coyote mistaken for dog now bonding with another rescued pup

“It was right where the wall jutted up. I had no chance,” Young insisted.

“It felt good,” Williamson assured. “Not just to get the first home run, but to have it a meaningful one.”

David Price pitches against the San Francisco Giants in the second inning at AT&T Park on June 8, 2016. (Photo by Ezra Shaw/Getty Images)

David Price pitches against the San Francisco Giants in the second inning at AT&T Park on June 8, 2016. (Photo by Ezra Shaw/Getty Images)

Price (7-3) went the distance, allowing the two runs on just three hits in eight innings. He walked two and struck out seven in his first complete game of the season and 15th of his career.

The two home runs he allowed for his ninth and 10th in 13 starts.

“It’s a loss. You have to take the good with the bad,” Price said. “It was a good ballgame. It’s my best outing of the year. I want to continue to pitch like this and build on it.”

Bumgarner, who allowed Young’s fourth-inning homer, limited the Red Sox to just four hits. He walked one and struck out five in holding the opposition to one run or fewer for a sixth consecutive start.

Matt Duffy had the only non-homer for the Giants, a second-inning single.

The Giants never put a runner in scoring position in the game, scoring only on the home runs. Their three other baserunners, who reached on a single and two walks, never advanced past first base.

Young and Mookie Betts combined for four of the five hits for Boston, the majors’ leader in runs scored.

The loss was just the Red Sox’s fifth in 14 games against the Giants.

“It was as billed. Both guys were locked into a low-scoring game,” Red Sox manager John Farrell assessed. “It turns out to be a one-pitch swing.”

Young’s homer to left field came in the fourth inning and opened the scoring. It was his fifth of the season and the second of his career against Bumgarner in 22 at-bats.

Belt got the Giants even in the bottom of the frame, bombing a Price curveball into San Francisco Bay beyond the right-field wall. It was Belt’s seventh homer of the season.

The “Splash Hit” was the 69th by a Giant in the 17-year history of the ballpark. It was the fifth of Belt’s career and the first for a Giant since Belt took San Diego’s Andrew Cashner into the water Sept. 25, 2014.

MORE NEWS: New England Living: Behind the scenes at WaterFire in Providence

NOTES: The last Giant to give his team the lead in the eighth inning or later with his first career home run before LF Mac Williamson did it Wednesday night had been INF John Patterson on Sept. 1, 1993. … Giants C Buster Posey (nerve irritation in right thumb) did not play for a third consecutive game. It marked the first time he hadn’t caught a LHP Madison Bumgarner start in his last 46 outings, dating back to Sept. 17, 2014. … Giants RF Hunter Pence (torn hamstring) left the team Wednesday to fly to Dallas, where he is scheduled to undergo surgery on Thursday. He is expected to be out at least two months. … With Posey and Pence out of the lineup, Giants 3B Matt Duffy batted cleanup for the first time in his major league career. … For the second night in a row, the Red Sox opted not to start DH/1B David Ortiz at first base in the National League ballpark. Ortiz, like six Red Sox starters, had never faced Bumgarner in his career. … Boston 2B Dustin Pedroia hit safely in his 15th consecutive game, the longest run in the majors. A Red Sox player has held the majors’ longest active hitting streak every day since May 3.