SAN FRANCISCO -- Right-hander Tim Lincecum ran his streak of consecutive dominant starts to four Friday night, shutting out the Arizona Diamondbacks on three hits in seven innings in the San Francisco Giants' 5-0 win.

Third baseman Pablo Sandoval had three hits, including his 11th home run of the season, and three RBIs, highlighting a 10-hit attack that allowed the Giants to win at AT&T Park for just the fifth time in their last 20 games.

Sandoval's homer, a two-run shot in the first inning off right-hander Mike Bolsinger (1-6), ended a run among Diamondbacks starting pitchers of not having allowed a home run in 42 consecutive innings.

The home run was just the Giants' 15th in their last 31 games.

That was all the offensive support Lincecum and two relievers needed en route to the Giants' eighth shutout of the season.

Lincecum (9-5) has been involved in three of the shutouts in his last four starts, a stretch he began with a no-hitter against the San Diego Padres on April 25. He has allowed just one run and 10 hits in 30 1/3 innings during that stretch.

The former two-time Cy Young Award winner ran his string of consecutive shutout innings at home to 27, the longest for a Giants pitcher in 12 years.

In beating the Diamondbacks for just the ninth time in 19 career decisions, Lincecum gave up doubles to third baseman Martin Prado and catcher Miguel Montero in the second and fourth innings, respectively, and a seventh-inning single to left fielder Mark Trumbo. He stranded all three on second base.

Trumbo was playing for the first time since suffering a stress fracture in his left foot on April 21. He was activated off the disabled list Friday, started in left field and went 1-for-4.

Lincecum walked two and struck out six, lowering his ERA, which stood at 4.90 before his no-hitter, to 3.66.

Right-hander Juan Gutierrez and lefty Jeremy Affeldt combined for two shutout innings, allowing two hits.

First baseman Brandon Belt reached base three times, twice on singles, and scored a run for the Giants, who outhit the Diamondbacks 10-5.

Bolsinger gave up one run in 7 2/3 innings the first time he saw the Giants last month. But he was over that number three batters into the rematch, thanks to Sandoval's first-inning blast into the right-field pavilion that also scored Belt, who had singled.

The Giants doubled the advantage to 4-0 in the second inning. Lincecum helped his own cause with a run-scoring bunt on a safety squeeze after shortstop Brandon Crawford had driven in center fielder Tyler Colvin with an RBI single.

Sandoval added to his RBI total in the fifth inning, doubling in right fielder Hunter Pence to push the lead to 5-0.

Bolsinger was pulled for a pinch hitter in the sixth, having allowed five runs and eight hits in five innings. He walked two and struck out five.

NOTES: All 10 games of the three previous Diamondbacks-Giants series this season were decided by four or more runs. ... Each team welcomed back a key offensive performer before the game. The Diamondbacks reinstated LF Mark Trumbo from the disabled list. He had been out since suffering a stress fracture in his left foot on April 21. The Giants activated 2B Marco Scutaro from the DL. He was in uniform for the first time this season after injuring his back during spring training. ... Diamondbacks OF Roger Kieschnick (optioned to Triple-A Reno) and Giants 2B Brandon Hicks (designated for assignment) were the roster casualties to create space for Trumbo and Scutaro, respectively. ... Diamondbacks C Miguel Montero got the nod over Giants C Buster Posey when National League manager Mike Matheny chose a catcher to replace injured C Yadier Molina for Tuesday's All-Star Game. Montero led all major league catchers in RBIs (52) at the time of the announcement Friday afternoon. ... Giants first-round pick Tyler Beede formally signed his first professional contract and toured AT&T Park on Friday afternoon. The right-hander will begin his career with the Giants' affiliate in the Arizona Rookie League.