PHOENIX — Matt Moore is enjoying being part of a playoff race.

Moore struck out 11 in seven innings, Hunter Pence hit a key two-run double and the San Francisco Giants beat Zack Greinke and the Arizona Diamondbacks 5-3 on Sunday for a series sweep.

The Giants pulled within three games of NL West-leading Los Angeles, which lost 3-0 at Miami. San Francisco leads the wild-card standings.

Moore (10-11) gave up two runs and eight hits, striking out four straight batters at one point. The left-hander improved to 3-4 in eight starts since he was acquired in a trade with Tampa Bay.

"It's definitely normalized. I can't really say what it was but it felt different," Moore said of his transition to a contender. "Maybe it was looking down and seeing orange on my shoes or looking and seeing (catcher Buster Posey's) glove. Right now, in the middle of this race, it's exciting to wake up in the morning and know where we are."

The Giants swept a road series from Arizona for the second time this season and sent the Diamondbacks to their sixth straight loss.

Pence, who had eight hits in the series, came up with another clutch swing against Randall Delgado in the seventh, doubling in Angel Pagan and Brandon Crawford with two out to give the Giants a 5-2 lead.

"Quite a series, wasn't it? We've seen him get on these runs before and it's fun to watch," Giants manager Bruce Bochy said of Pence. "It's inspirational baseball and gets the other guys going."

Greinke (12-6) allowed three runs and six hits in six innings. His undoing was in the sixth, when he walked the bases loaded and gave up the tying and go-ahead runs.

Greinke has lost back-to-back starts for the first time since early April.

Denard Span, who went 30 at-bats without a hit until Saturday night, led off the game with a drive to right field. It was Span's fifth career leadoff home run and first this season.

The Diamondbacks tied it in the second on Jake Lamb's triple and a shallow single to centre by Brandon Drury. Arizona went ahead 2-1 on Chris Owings' double and a two-out, two-strike single from Welington Castillo in the fifth.

Moore settled down after that.

"Seven solid innings allowed us to use the bullpen the way we wanted," Bochy said.

San Francisco rallied in the sixth. With the bases full, Brandon Belt slapped an opposite-field single into left field, and then Joe Panik's grounder to first allowed Crawford to come home for a 3-2 Giants lead.

"I felt pretty good. Not perfect, but then the last inning, just missing by a little bit on just about every pitch," Greinke said. "Getting behind and trying to make a good pitch, and just missing by little bit again. It ended up not being a good inning."

Castillo homered off Sergio Romo in the eighth, but that was it for the Diamondbacks. Hunter Strickland got four outs for his third save of the season.

REMEMBERING 9-11

On the 15th anniversary of the Sept. 11 attacks, the Diamondbacks honoured military members and first responders in a pregame ceremony that included a bagpipe ensemble's music.

TRAINER'S ROOM

Giants: RHP Derek Law (elbow) is still on track to come off the disabled list Tuesday or Wednesday, Bochy said. He's throwing to hitters on Monday.

Diamondbacks: LHP Andrew Chafin's MRI revealed nothing more than swelling in his shoulder, so he'll go six or seven days without throwing. Manager Chip Hale said he'd like to get Chafin in for a game or two before the season ends but acknowledged it might not happen. "At this point, we just want him to leave here with a healthy arm," Hale said. "I'm not counting on anything right now."

UP NEXT

Giants: RHP Jeff Samardzija (11-9) is 3-0 against the San Diego Padres this season. He faces them in the series opener on Monday night in San Francisco.

Diamondbacks: RHP Shelby Miller (2-11) will be making his ninth career start against Colorado when Arizona opens a series at home against the Rockies on Monday.