PHOENIX (AP) -- Johnny Cueto started the night with a bad stomach ache and ended it with his 12th victory of the season.
With help from a cast of reserves filling in for the injured and the weary usual starters, Cueto settled down after a rocky start and the San Francisco Giants beat the Arizona Diamondbacks 6-4 on Friday night.
"He was pretty sick," manager Bruce Bochy said. "His stomach was bothering him. I didn't know if we were going to have to get him after the first or second inning. He just wasn't doing well."
Cueto (12-1) allowed four runs in the first three innings and none in the next four.
He said he started feeling ill while warming up in the bullpen.
"I felt like throwing up," Cueto said through an interpreter. "... I never thought of not starting. I didn't feel well. My legs were weak and I felt like I was probably going to faint, but the trainers gave me liquids and just helped get me stronger."
After about the fourth inning, Cueto said, he started feeling better.
With several usual starters on the disabled list, catcher Buster Posey having the night off (after 20 straight games) and center fielder Denard Span a late scratch with a stiff neck, the Giants depth shone through.
Conor Gillaspie fell a home run shy of the cycle, Trevor Brown doubled in two runs , Grant Green singled in two more and Jarrett Parker homered as the Giants improved to 5-0 at Chase Field this season.
"This organization has done a tremendous job of bringing not just good baseball players but quality people and quality teammates," Gillaspie said. "That's something that's very noticeable from every guy they bring up."
Gillaspie, playing at third with Mike Duffy on the 15-day disabled list, has been on a tear. He's batting .460 (17 for 37) n his last 37 at-bats. He tripled in the first inning, doubled and scored in the fourth and singled and scored in the sixth.
They are tied with the Chicago Cubs for most victories in the National League with 51.
Welington Castillo and Jake Lamb homered for the Diamondbacks. Lamb hit a home run in his third consecutive game for the first time in his career.
Cueto allowed seven hits in seven innings and struck out nine with no walks while improving to 8-0 on the road. He joined the Cubs' Jake Arrieta as the only 12-game winners in the National League.
The Diamondbacks had runners at first and third with no outs against closer Santiago Casilla in the ninth. But Yasmany Tomas hit into a double play, Phil Gosselin walked, pinch-hitter Peter O'Brien struck out and Casilla escaped with his 18th save in 22 tries.
Shelby Miller (2-8) allowed six runs and eight hits in six innings and took the loss. He is 0-6 at home, where the Diamondbacks are 13-29.
San Francisco took the lead with two runs in the sixth. Parker and Gillaspie singled and, with two outs, Brown doubled down the right field line to bring both home and put the Giants up 5-4.
Arizona manager Chip Hale was asked whether he considered walking Brown with Cueto's spot up next.
"The pitcher and the catcher know the pitcher is on deck so they are trying to pitch, not give him a 'cookie,'" Hale said. "I think the pitch was supposed to be way out and it kind of leaked back over and he did a great job hitting it down the right-field line."
Miller said Brown hit a good pitch.
"Basically staying away," Miller said. "In my eyes it was a perfect pitch. It might have been a little on the plate but not a bad pitch by any means."
The Diamondbacks jumped on Cueto for three runs in the first inning. Doubles by Jean Segura and Paul Goldschmidt scored one, then Castillo hit Cueto's 3-2 pitch into the seats in left center to bring home two more.
Giants: RHP Matt Cain (right hamstring strain) will pitch in an Arizona Fall League game on Saturday.
Diamondbacks: RHP Zack Greinke will miss his next scheduled start on Monday (sore left oblique) but no decision has been made on whether to place him on the DL.
Giants: RHP Jeff Samardzija (8-5, 3.91 ERA), looks to rebound from his Tuesday night start, when he allowed six runs in six innings.
Diamondbacks: LHP Patrick Corbin (4-6, 4.99) takes the mound for Arizona in the second game of the three-game series.