SAN FRANCISCO (AP) — Madison Bumgarner still feels there are things that need worked on in his game, though it's starting to come together for the Giants star.

Bumgarner and Zack Greinke both pitched well in a showdown of NL West aces, but Welington Castillo hit a two-run homer in the seventh inning to help the Arizona Diamondbacks beat San Francisco 2-1 on Wednesday night.

"I was just trying to make pitches and slow everything down," Bumgarner said. "I still don't feel like I'm where I want to be but it was definitely better, for sure."

Greinke (1-2) got his first win with Arizona and remained undefeated against the Giants — he's 8-0 in 11 starts against San Francisco and 3-0 against Bumgarner. He gave up a run on six hits over 6 2/3 innings, walking one and striking out seven.

"Bum did such a great job giving us a chance to win. Made one mistake," Giants manager Bruce Bochy said. "It's never fun. I don't care what time of year it is. We are in a tough rut, but you're going to go through this."

Bumgarner (1-2) went seven innings, giving up the two runs on five hits. He walked one and struck out eight as the Giants lost their fourth straight and seventh of eight.

"Both pitchers were spot on," Diamondbacks manager Chip Hale said. "It took one pitch that Bumgarner left in the zone for us to hit. For a while I thought we might be going 20 innings."

Castillo hit his second home run of the series and his third of the season, taking Bumgarner deep on an 0-2 pitch. He's driven in four runs during the series and hit .325 (14 for 44) at AT&T Park in his career.

"I felt pretty good about the pitch I made to Castillo," Bumgarner said. "I was more upset about the pitch before that that put Tomas on. I was going backdoor cutter and it ran back all the way across the plate."

Gregor Blanco hit a one-out triple and Angel Pagan followed with an RBI single in the seventh to end an 18-inning scoreless streak for the Giants against Arizona. Blanco had two hits.

"We got a great pitching effort, we're just missing some timely hits," Bochy said. "We finally got one late in the game but we had a couple chances early."

POSEY'S PURPOSE

A chance meeting between Kristen Posey and Melissa Wiggins motivated Kristen and her husband, Giants catcher Buster Posey, to help raise funds for pediatric cancer research and awareness. Melissa's son, 4-year-old Cannon Wiggins has been diagnosed with neuroblastoma, most common cancer in childhood and infancy. The Poseys are parents of 3-year-old twins and immediately identified with Wiggins. "I had no idea the lack of funding," Kristen Posey said. "Once I found that out, I did not want to sit back and do nothing. That's easy to do. It's not all smiling children without hair. What they go through is torture, and we want to do something."

TRAINER'S ROOM

Diamondbacks: IF Paul Goldschmidt has reached base in 21 of his last 22 games against the Giants. ... IF Jake Lamb, who was out of the starting lineup against a left-hander, has reached base safely in 18 of his past 21 games on the road. He delivered a pinch-hit double in the eighth. ... OF Yasmany Tomas singled and scored on Castillo's homer and has reached base safely in eight straight.

Giants: OF Hunter Pence was given a routine day off. Blanco started in his place. Pence popped up with a runner on third as a pinch-hitter in the seventh for Bumgarner, who owns an ERA of 1.58 in 11 home games against the Diamondbacks.

UP NEXT

Diamondbacks: RHP Shelby Miller (0-1, 8.53) starts Thursday's series finale. He's 2-1 with a 1.71 ERA in four starts against the Giants.

Giants: RHP Johnny Cueto (3-0, 3.38) will start in Thursday's matinee. He's 6-1 with a 2.54 ERA in eight games against the Diamondbacks. His next win will be No. 100.