The Associated Press

SAN FRANCISCO - Pablo Sandoval isn't getting regular at-bats these days, but he's making the most of his opportunities.

Sandoval homered and doubled in his second three-hit game this season, scoring the go-ahead run on Kevin Pillar's two-out single in the eighth inning to lift the San Francisco Giants over the Cincinnati Reds 6-5 on Sunday.

Sandoval hit a two-run, opposite-field homer to left in the first off Tyler Mahle that tied the score 2-2, his sixth home run this season. He singled in the sixth.

Sandoval was in the lineup at first base to give Brandon Belt, who is experiencing right knee inflammation, some extra rest.

Manager Bruce Bochy said Sandoval affords him that luxury.

"He's one of those guys who can sit and come up there and give you a good at-bat, whether it's pinch hit or he gets his starts," Bochy said. "The guy just has a knack for coming through when you need him."

San Francisco trailed 5-4 when Evan Longoria singled off David Hernndez (0-2) leading off the eighth. Sandoval doubled, Mac Williamson hit a run-scoring grounder and Pillar singled in front of center fielder Nick Senzel for his team-leading 22nd RBI. Sandoval slid home as the rookie's throw from about 260 feet was up the third-base line.

Sandoval also had a three-hit game at Toronto on April 23.

He was released from a $95 million, five-year contract with Boston two years ago, and the Giants are paying him the $555,000 major league minimum.

Belt made a big contribution, too, coming in as a pinch-hitter in the seventh and hitting a tying, two-run homer - his sixth - on a hanging curveball from Mahle.

Reds manager David Bell said acknowledged he had Zach Duke available to face Belt, but he wanted to give Mahle a chance to get through the inning.

"We've talked about him getting stronger as the game goes on and we liked the way he was throwing," Bell said. "He'll continue to get opportunities like that."

Mahle allowed four runs and six hits in 6 1/3 innings. He is 0-5 in eight starts this season.

The Giants overcame three deficits on Sunday.

Pillar said the team's 12-11 comeback win against the Reds on May 3, in which the Giants rallied from an eight-run deficit, was a turning point.