Giants rookie Chris Shaw hit a two-run single in the eighth inning and San Francisco rallied to beat San Diego 5-4 on Tuesday night, assuring that the rebuilding Padres will finish last in the NL West.

Hunter Pence homered, doubled and drove in three runs for the Giants.

More Images
San Diego Padres' Franmil Reyes hits a two-run home run during the fifth inning of a baseball game against the San Francisco Giants on Tuesday, Sept. 18, 2018, in San Diego. (AP PhotoGregory Bull)

Giants rookie Chris Shaw hit a two-run single in the eighth inning and San Francisco rallied to beat San Diego 5-4 on Tuesday night, assuring that the rebuilding Padres will finish last in the NL West.

A fan grabs the ball on a two-run home run by San Diego Padres' Franmil Reyes, over the glove of San Francisco Giants left fielder Chris Shaw during the fifth inning of a baseball game Tuesday, Sept. 18, 2018, in San Diego. (AP PhotoGregory Bull)

Shaw's bases-loaded flare fell in just in front of diving left fielder Hunter Renfroe, and Nick Hundley and Brandon Crawford came racing home to give the Giants the lead. Craig Stammen (8-3) loaded the bases with no outs before getting Pence to ground into a force at home, but then gave up Shaw's decisive hit.

A fan celebrates after grabbing a two-run home run by San Diego Padres' Franmil Reyes, left, over the glove of San Francisco Giants left fielder Chris Shaw, gesturing, during the fifth inning of a baseball game Tuesday, Sept. 18, 2018, in San Diego. (AP PhotoGregory Bull)

Reyes gave the Padres a 4-3 lead on his two-run homer in the fifth off lefty Derek Holland that had to withstand a video review for potential fan interference. It was determined that a fan who went for the ball didn't interfere with Shaw in left field. It was Reyes' 16th and it came with pinch-hitter A.J. Ellis aboard on a leadoff walk.

San Francisco Giants' Nick Hundley, right, reacts with teammate Chris Shaw (26) after scoring on a double by Hunter Pence during the fourth inning of a baseball game against the San Diego Padres on Tuesday, Sept. 18, 2018, in San Diego. (AP PhotoGregory Bull)

Padres rookie lefty Joey Lucchesi yielded three runs and seven hits in five innings. He struck out eight and walked one.

San Francisco Giants relief pitcher Will Smith, right, and catcher Nick Hundley celebrate after the Giants defeated the San Diego Padres 5-4 in a baseball game Tuesday, Sept. 18, 2018, in San Diego. (AP PhotoGregory Bull)

Padres: LHP Robbie Erlin (3-7, 4.27) is looking for better luck after tying his career high by losing four straight starts.

Freddy Galvis had four hits and scored twice for the Padres, who dropped to 60-92, one more loss than last year with 10 games to play. Ownership expected the team would improve from last season, when it finished 71-91, seven games better than San Francisco.

San Diego Padres' Franmil Reyes hits a two-run home run during the fifth inning of a baseball game against the San Francisco Giants on Tuesday, Sept. 18, 2018, in San Diego. (AP PhotoGregory Bull)

San Diego Padres' Franmil Reyes hits a two-run home run during the fifth inning of a baseball game against the San Francisco Giants on Tuesday, Sept. 18, 2018, in San Diego. (AP PhotoGregory Bull)

Shaw's bases-loaded flare fell in just in front of diving left fielder Hunter Renfroe, and Nick Hundley and Brandon Crawford came racing home to give the Giants the lead. Craig Stammen (8-3) loaded the bases with no outs before getting Pence to ground into a force at home, but then gave up Shaw's decisive hit.

Pence had a big night otherwise, hitting a two-run homer in the second, his third, and adding an RBI double in the fourth to give the Giants a 3-2 lead.

Sam Dyson (4-3) pitched the seventh for the win. Will Smith worked the ninth for his 14th save, allowing Galvis' one-out double before striking out rookie Franmil Reyes and Renfroe.

A fan grabs the ball on a two-run home run by San Diego Padres' Franmil Reyes, over the glove of San Francisco Giants left fielder Chris Shaw during the fifth inning of a baseball game Tuesday, Sept. 18, 2018, in San Diego. (AP PhotoGregory Bull)

A fan grabs the ball on a two-run home run by San Diego Padres' Franmil Reyes, over the glove of San Francisco Giants left fielder Chris Shaw during the fifth inning of a baseball game Tuesday, Sept. 18, 2018, in San Diego. (AP PhotoGregory Bull)

Reyes gave the Padres a 4-3 lead on his two-run homer in the fifth off lefty Derek Holland that had to withstand a video review for potential fan interference. It was determined that a fan who went for the ball didn't interfere with Shaw in left field. It was Reyes' 16th and it came with pinch-hitter A.J. Ellis aboard on a leadoff walk.

Reyes also hit an RBI single in the third and Renfroe had an RBI double in the first.

Holland allowed four runs and five hits in five innings. He struck out six and walked two.

A fan celebrates after grabbing a two-run home run by San Diego Padres' Franmil Reyes, left, over the glove of San Francisco Giants left fielder Chris Shaw, gesturing, during the fifth inning of a baseball game Tuesday, Sept. 18, 2018, in San Diego. (AP PhotoGregory Bull)

A fan celebrates after grabbing a two-run home run by San Diego Padres' Franmil Reyes, left, over the glove of San Francisco Giants left fielder Chris Shaw, gesturing, during the fifth inning of a baseball game Tuesday, Sept. 18, 2018, in San Diego. (AP PhotoGregory Bull)

Padres rookie lefty Joey Lucchesi yielded three runs and seven hits in five innings. He struck out eight and walked one.

UP NEXT

Giants: RHP Chris Stratton (10-9, 4.66 ERA) is scheduled to start the series finale Wednesday night. He's coming off his first career shutout, 2-0 against Colorado.

San Francisco Giants' Nick Hundley, right, reacts with teammate Chris Shaw (26) after scoring on a double by Hunter Pence during the fourth inning of a baseball game against the San Diego Padres on Tuesday, Sept. 18, 2018, in San Diego. (AP PhotoGregory Bull)

San Francisco Giants' Nick Hundley, right, reacts with teammate Chris Shaw (26) after scoring on a double by Hunter Pence during the fourth inning of a baseball game against the San Diego Padres on Tuesday, Sept. 18, 2018, in San Diego. (AP PhotoGregory Bull)

Padres: LHP Robbie Erlin (3-7, 4.27) is looking for better luck after tying his career high by losing four straight starts.

More AP MLB: https://apnews.com/tag/MLB and https://twitter.com/AP_Sports

San Francisco Giants relief pitcher Will Smith, right, and catcher Nick Hundley celebrate after the Giants defeated the San Diego Padres 5-4 in a baseball game Tuesday, Sept. 18, 2018, in San Diego. (AP PhotoGregory Bull)

San Francisco Giants relief pitcher Will Smith, right, and catcher Nick Hundley celebrate after the Giants defeated the San Diego Padres 5-4 in a baseball game Tuesday, Sept. 18, 2018, in San Diego. (AP PhotoGregory Bull)