Medica singled after a 14-pitch at bat, with Guzman watching intently from the on-deck circle. Guzman then homered in a four-run fourth inning.
"I saw a lot of pitches and I hit it good," Guzman said. "He made the pitcher throw a lot of pitches and then he gets the hit."
Hunter Pence, who reached a tentative agreement on a $90 million, five-year contract before the game, hit a two-run homer for the Giants. San Francisco had won three in a row.
Eric Stults (11-13) pitched seven effective innings to win his third straight start after going 0-6 in his previous 10 starts. He also helped himself with an RBI single during a four-run fourth.
"I made some adjustments and was able to follow through on them," Stults said. "Every player wants to end on a good note and sometimes you have to battle the storm a little and keep pushing through."
Stults allowed three runs on seven hits. He did not walk a batter and struck out three.
Yusmeiro Petit (4-1) lasted a season-low 3 2/3 innings, giving up five runs and seven hits.
"I felt good all the way around," Petit said. "This is a learning experience for me because when I get into big trouble I have to find a way to get out of it."
Denorfia led off the game with his career-best 10th home run.
Angel Pagan doubled to open the bottom of the first and scored when Sandoval doubled with two outs.
Pence hit his 27th homer in the third to put the Giants ahead 3-1. His homer total is the highest for the Giants since Barry Bonds hit 28 in 2007.
Petit retired the first two batters in the fourth and then gave up six consecutive hits, including the long at bat by Medica, before being replaced by George Kontos.
"He was throwing everything," Medica said. "He kept making good pitches and I was fortunate to keep getting a piece of them until I finally got one fair."
Chase Headley doubled ahead of Medica. Guzman hit his homer and consecutive singles from Alexi Amarista, Chris Robinson, making his first major league start, and Stults produced another run and ended Petit's day.
Stults, who retired his last nine hitters, threw a career-high 203 2/3 innings this season.
"It's definitely a milestone," Stults said. "The goal was to make it through the season healthy and try to be reliable."
The Padres added four runs in the ninth on Gyorko's 22nd home run, a two-run shot, and RBI singles from Denorfia and Reymond Fuentes.
Gyorko has the most home runs by a rookie second baseman since Dan Uggla hit 27 for the Marlins in 2006.
Giants INF Brandon Belt will be working on his versatility during the offseason according to manager Bruce Bochy. ... RHP Guillermo Moscoso (2-2, 4.21) will start Sunday's season finale for the Giants. It's his first start since Aug. 4. ... RHP Tyson Ross (3-8, 3.10) makes the start for the Padres on Sunday. He has an ERA of 2.80 over his last 12 starts. ... Denorfia hit his second leadoff homer of the season and seventh of his career. ... Medica had his first career three-hit game.
Vladimir Guerrero Jr., Bo Bichette, Cavan Biggio and Kacy Clemens are among the four sons of former major league players to take the field in the Blue Jays' 11-3 win against Team Canada.
Braden Halladay, son of Roy Halladay, throws a scoreless inning for Team Canada in their 11-3 loss against Toronto.
No one comes out to play left field for the Phillies to start the top of the fifth, which leads to a minor delay before Andrew Pullin emerges from the dugout.
Aaron Judge suggested Orioles shortstop Manny Machado would look nice in Yankee pinstripes, earning him a warning on tampering. Machado says it was no big deal, though: 'Everyone always jokes' about those things.
Blue Jays pitcher Marcus Stroman, who has been dealing with inflammation in his pitching shoulder, says he expects to make his April 1 start.
Oakland Athletics RHP Jharel Cotton injured his elbow earlier this week against the San Francisco Giants. He was expected to be in Oakland's starting rotation this season.