PITTSBURGH -- A day after one of their worst offensive games of the season, the San Francisco Giants had their best.
Conor Gillaspie also homered during the fourth among his four hits and Gregor Blanco scored three times for San Francisco, which won a night after having an eight-game winning streak snapped in a 1-0 loss to Pittsburgh.
"Whatever happened last night, this is just another game," Pagan said. "Obviously we were trying to win a ballgame (Monday), but we didn't. Today we just came with a brand new opportunity to go out there and try to put together the best at-bats possible."
The Giants did plenty of that Tuesday. San Francisco, which also had a five-run eighth inning, had season highs in runs and hits (22).
Cueto (11-1) moved into a tie for the National League lead in wins by allowing one run on four hits in 6 2/3 innings. He extended his career-best winning streak to eight and improved to 19-4 against the Pirates.
"I wasn't aware of the number, but I know that after I lost the (2013) wild-card game against them, I told myself I needed to just concentrate and try to win as many games as I can," Cueto said.
Recalled earlier in the day from Triple-A Indianapolis, Pittsburgh's Wilfredo Boscan (1-1) allowed one baserunner over the first three innings of his first major league start, but did not retire any of the seven batters he faced in the fourth.
Pittsburgh (34-37) has lost 11 of 13 to fall into sixth place in the NL wild-card race.
The first nine Giants who came up in the fourth inning reached base.
After Brandon Crawford drove in the game's first run by drawing an 11-pitch walk, Pagan took the next pitch Boscan threw into the seats in right-center for his third homer of the season and second grand slam of his career.
"I don't know whether the at-bat to Crawford took some steam out of him," Pirates manager Clint Hurdle said, "but after that, you walk a guy and the mentality is you have to throw a strike and you throw a strike to a dead-red fastball hitter, the guy has a chance to ambush you."
After Blanco doubled, Gillaspie homered.
"We finally broke through," Giants manager Bruce Bochy said.
"It's always good for hitters to get the second look and have a better idea what his ball is doing,"
It got so bad for the Pirates that Erik Kratz, their 36-year-old, third-string catcher, pitched the ninth inning. He allowed two hits but no runs and had a strikeout in what was his second pitching appearance of the season (April 26 for Houston against Seattle).
Giants: 3B Matt Duffy was placed on the disabled list because of a left Achilles strain (OF Mac Williamson from Triple-A Sacramento to take his roster spot). Bochy said Gillaspie would get "the lion's share" of the playing time at third base in Duffy's stead, although Ramiro Pena also will play some. Williamson gives San Francisco a right-handed bat that Bochy said will start the next two days against Pittsburgh left-handers. Duffy was fitted for a walking boot Tuesday, and Bochy said he would be out for close to three weeks.
Pirates: OF Starling Marte left the game in the eighth inning because of left foot discomfort sustained tracking down Ramiro Pena's triple. He was being evaluated by Pirates medical staff after leaving the game but there was no immediate update on the injury's seriousness. ... Stewart's appearance was his first in four days since experiencing knee soreness.
Giants: RHP Jeff Samardzija (8-4, 3.14 ERA) is coming off the eighth complete game of his career Friday at Tampa Bay. He will make his 11th career start against the Pirates, tying for the most of any opponent. He has a 2.25 ERA vs. Pittsburgh.
Pirates: LHP Francisco Liriano (4-7, 5.03) has lost his past four starts, giving up 20 runs (16 earned) in 21 innings over that span. But he has won his past four outings against the Giants, posting a 2.13 ERA against them in that span.
Jacob deGrom GOAT tracker -- Where Mets ace's season stands among the best in MLB history
New York's No. 1 starter is off to one of the greatest starts ever. Keep up with deGrom's record pace, most amazing numbers and where things could go from here.
Major League Baseball's crackdown on sticky substances begins with regular checks on pitchers Monday
The crackdown by Major League Baseball for sticky stuff that pitchers might use to doctor baseballs began with regular checks on Monday.
DeGrom dominates after shoulder scare, Mets beat Braves 4-2
— Jacob deGrom put Mets fans at ease with a bevy of triple-digit heaters.
'That's almost not fair' DeGrom makes incredible catch
Jacob deGrom catches a line drive hit right back at him by Guillermo Heredia.
DeGrom checked for foreign substances in Braves-Mets game
Jacob deGrom is the first MLB pitcher to be checked for foreign substances under MLB's enhanced enforcement of foreign substances as he headed to the dugout in the first inning.
Preparing for a large crowd, Baseball Hall of Fame induction ceremony returns to standard seating format
Preparing for the long-awaited ceremony to honor the 2020 class on Sept. 8, Baseball Hall of Fame officials said Monday that tickets will not be required for the induction event's free lawn seating area.