Headley continued his breakout season with a two-run homer, his 30th. He finished with three RBIs to tie Ryan Braun for the NL lead with 112.
"It's exciting. I think at the end of the year I'll really be able to reflect about it a little bit more," said Headley, whose two-run homer off Madison Bumgarner in the third gave the Padres a 4-3 lead. "You try not to think about it, but when you're right on the doorstep, you want to get over the hump. It was a great feeling when I hit it, and it was an even better feeling coming in the dugout and having all the guys more happy than I was. That was really special."
The ball caromed back onto the field and one of the Giants' outfielders tossed it into the Padres' bullpen. Justin Hatcher, one of the Padres' bullpen catchers, gave the ball to Headley.
"That was awesome," Headley said. "You don't always get the opportunities to get those. You never know if it's that's going to be the last one or the best one. It's nice to have those keepsakes."
It's San Diego's first 30-homer season since Adrian Gonzalez had 31 in 2010, and the 17th time it's been done in team history. Headley also had an RBI grounder in the first and scored three runs.
San Francisco's Buster Posey, who started at catcher a night after being hit in the throat with a wild pitch, went 2 for 2 with a walk to raise his average to .337 and increase his lead in the NL batting race over Pittsburgh's Andrew McCutchen. McCutcheon went 1 for 5 to drop to .329. Suspended outfielder Melky Cabrera of the Giants has a .346 mark but won't qualify for the batting crown at his own request after a positive drug test.
The Padres scored as many runs Saturday night as they did in being outscored 19-7 during a three-game losing streak. Chris Denorfia had three hits and scored twice.
Xavier Nady drove Stults' next pitch to deep center field. It would have gone out if not for Maybin's leaping to get his glove over the wall for a spectacular leaping catch.
"I got a really good read on the ball and I was able to get back there and get my steps right," Maybin said. "I was able to one quick little last peek at the wall. It was a huge play and we came back and responded really well. That play was huge tonight."
Maybin made a diving catch of Brandon Belt's sinking liner for the second out of the ninth.
"I got another good read, a really good jump," Maybin said. "Even late in the game, when it seems like the game's out of reach, you can never take any plays off. I was a little disappointed how I swung the bat tonight, so I had to take it out on somebody. Why not the other team?"
Stults said the first inning could have been ugly if not for Maybin's catch and the nice play Headley made at third to throw out leadoff batter Angel Pagan.
"That really stopped the bleeding. I've got to give those guys credit," Stults said. "The catch Cam made is probably going to be one of the top 10 plays all season in baseball."
San Diego got two runs back in the bottom of the first on Headley's RBI grounder and Yasmani Grandal's sacrifice fly.
Jesus Guzman and Grandal each drove in two runs for the Padres. Guzman hit a solo homer with two outs in the third and an RBI double in the fifth. Grandal hit an RBI single in the fifth.
Stults (8-3) allowed three runs and six hits in six innings, struck out five and walked three.
Bumgarner (16-11) allowed five runs, four earned, and four hits in four innings. He struck out four and walked two. Bumgarner had won his last four decisions against San Diego, including going 3-0 with a 3.08 ERA in four previous starts against the Padres this season.
"He was a little off," manager Bruce Bochy said. "It affected his command. He was battling himself out there. He might be thinking about it too much."
Bumgarner, who has struggled since the end of August, said he had a problem with his mechanics.
"We definitely have some time to work on it," he said. "I'm not worried about anything. I have to be able to make pitches when it counts."
San Francisco's Marco Scutaro singled in the fifth to extend his hitting streak to a career-high 17 games, the longest active streak in the majors.
Posey was replaced by Eli Whiteside starting the bottom of the sixth. Giants manager Bruce Bochy said Posey was sore and his voice was raspy after being shaken up Friday night when a pitch from Ryan Vogelsong bounced in the dirt, ricocheted up and hit right underneath his hockey-style catcher's mask. Bochy said Posey is scheduled to have Sunday off, as are a number of other players. ... The series concludes Sunday when Tim Lincecum (10-15, 5.15) is scheduled to start opposite San Diego's Edinson Volquez (11-11, 4.13). Lincecum is coming off a 7-2 loss to Arizona in which he tied his season high by allowing seven earned runs.
Jose Canseco will not return to NBC Sports California as a pre- and post-game analyst on Oakland Athletics broadcasts after he issued a series of tweets regarding sexual harassment on Tuesday.
Right-handed reliever Tommy Hunter is close to a deal with the Phillies, according to sources.
Sources told ESPN's Buster Olney that relief pitcher Bryan Shaw's three-year deal with the Rockies is worth around $9 million per season. Shaw led the majors with 79 appearances last season with the Indians.
Free-agent slugger J.D. Martinez is headed to the winter meetings, where he is expected to meet with the Boston Red Sox and other potential teams. The Red Sox need power, and Martinez may be their top choice.
Tyler Chatwood's new contract with the Cubs might have to be reworked due to an escalator that could take effect based on a single Cy Young Award vote.
Buck Showalter's contract is up after 2018, but the veteran said Tuesday that he hopes to be the Orioles' manager in 2019 and beyond.