Buster Posey picked up right where he left off.

The star catcher hit a two-run homer his first time up Monday night after missing two weeks with a bruised left thumb, and the San Francisco Giants defeated the Los Angeles Dodgers 7-2 in the opener of a pivotal four-game series between the NL West rivals.

"I was wondering how that first at-bat was going to go after the long layoff. In Buster’s case, he is so important to this team, and having his presence behind the plate sometimes could even mitigate some potential rust at the plate," Giants manager Gabe Kapler said. "To see him come out, step up to the plate and hit a big home run for us was incredibly impressive. I thought he had great at-bats throughout the night."

CLICK HERE FOR MORE SPORTS COVERAGE ON FOXNEWS.COM

With the win, the Giants expanded their lead to two games over the defending World Series champion Dodgers. San Francisco has been in first place since May 31.

Posey and Wilmer Flores hit back-to-back homers in the first inning to give the Giants a 3-0 lead, The Dodgers countered in the bottom half with solo shots by Max Muncy and Justin Turner.

It remained 3-2 until the seventh, when San Francisco broke it open with four runs. Thairo Estrada — taking over at shortstop after All-Star Brandon Crawford was placed on the injured list due to a strained oblique — had the key hit with a two-run double.

The Giants' bullpen also came up huge by allowing one hit and one walk in six innings after Kevin Gausman pitched a season-low three innings. The All-Star right-hander — second in the majors with a 1.84 ERA — was activated from the Family Medical Emergency list after he missed the weekend series in St. Louis after his wife Taylor was hospitalized due to pregnancy complications.

"They really picked me up right there. To come in and shut down that lineup, especially the way they were swinging it, was impressive," Gausman said about the San Francisco bullpen. "That was the reason why we won the game."

Jarlín García (2-2), the second of five Giants relievers, got the win. San Francisco's bullpen retired 11 straight Dodgers batters until AJ Pollock led off the ninth with a single.

"When you get to the 'pen you’ve got to kind of go for the jugular and those guys kept us at bay tonight," Dodgers manager Dave Roberts said.

With one out in the first, Posey took advantage of a hanging slider from Tony Gonsolin (1-1) on a full count and launched it into the left-field stands for his 13th homer of the season. Posey drove in LaMonte Wade Jr., who led off the game with a double.

Two pitches after Posey's homer, Flores went deep to right for his 10th of the year. It was the sixth time this season the Giants hit back-to-back home runs.

The Dodgers quickly responded. Muncy crushed Gausman's fastball down the right-field line on the first pitch of the at-bat for his eighth homer against the Giants this season. Muncy is the sixth Dodgers player, and first since Ron Cey in 1978, to go deep at least eight times against the Giants in one year.

Turner followed with a drive into the center-field seats. It was the second time this month and seventh time this season the Dodgers went back-to-back.

San Francisco got breathing room in the seventh. Jason Vosler drove in Posey on a sacrifice fly with the bases loaded to make it 4-2. Estrada followed with a two-run double to left and came home when Austin Slater laced a double down the right-field line.

BETTER LATE THAN NEVER

According to Sportradar, this was the first time in the 2,526 regular-season games of the Giants vs. Dodgers rivalry that both teams hit back-to-back homers in the first inning.

FOR STARTERS

Gausman, who allowed two runs on three hits with three strikeouts and five walks, threw 80 pitches in three innings. Despite being away from the team, he threw a bullpen at LSU on Saturday and felt good in his pregame warmups, but couldn't carry that through to the game.

"I was really quick toward home plate," he said. "I can usually fix a mechanical adjustment during games but for some reason I couldn’t tonight."

Gausman issued back-to-back walks to Muncy and Turner to load the bases in the second inning but got out of the jam with a strikeout of Will Smith.

Gonsolin yielded three runs on five hits in 3 1/3 innings with four walks and three strikeouts. Only 39 of his 80 pitches were strikes.

When asked where his command is at the moment, Gonsolin said it's "really bad."

TRAINER'S ROOM

Giants: 2B Tommy La Stella (left hamstring strain and right thumb) started hitting again. The plan is to have him back in rehab games toward the middle or end of this week.

Dodgers: INF Gavin Lux was placed on the 10-day injured list due to a left hamstring strain. OF Zach Reks was recalled from Triple-A Oklahoma City to fill the roster spot.

UP NEXT

San Francisco LHP Alex Wood (8-3, 3.67 ERA) is 2-0 with a 2.25 ERA this month. Los Angeles had not announced a starter.