SAN FRANCISCO — Shelby Miller soaked it all in as he returned to the big leagues at last, cherishing pitching in front of a sellout crowd in the rival’s home ballpark after more than a month of making adjustments in the minors.

Miller still has some work to do going deeper into games. Yet this was a decent start to getting back to where he believes he belongs, and the right-hander was unflappable after falling behind in the first inning — something that before he admits might have thrown off his entire day.

Miller (2-10) was called up from Triple-A Reno and took the loss for Arizona in a 4-2 defeat to the San Francisco Giants on Wednesday. Pitching in the majors for the first time since July 6 and then being sent down on July 14, the 15-game winner with St. Louis in 2013 allowed two runs and six hits in six innings.

“It seems like when it rains it pours sometimes, the biggest thing you can do is just kind of block that out and realize you can either let that affect you, think the worst is happening and that this is going to continue, and that’s when things go downhill,” the 25-year-old Miller said. “The biggest thing is to try to eliminate it, those things are going to happen, and get on with your game.”

Matt Moore (2-3) struck out seven over 5 1-3 innings for his first career victory at AT&T Park. He gave up one run and five hits in his first game since losing a no-hit bid with two outs in the ninth inning at Dodger Stadium. He was backed by a sensational running catch on Paul Goldschmidt’s sixth-inning drive from center fielder Gorkys Hernandez, who crashed into the wall to make the play.

Manager Bruce Bochy was careful not to overwork Moore, who was done at 92 pitches after throwing 133 during the no-hit try at Los Angeles.

Buster Posey drove in two runs for San Francisco, which is in second place in the NL West behind the Dodgers.

Santiago Casilla relieved Sergio Romo with the bases loaded and two outs in the eighth and struck out Yasmany Tomas. Casilla finished for his 29th save, giving up Jake Lamb’s two-out homer in the ninth.

“I felt good mechanically, kind of a little jittery there in the first inning, just getting back in that atmosphere, which is always so much fun to be a part of games where fans are there,” Miller said of big league crowds.

Posey doubled home a run in the first. Hunter Pence added an RBI single later that inning in his second game back after missing three with a strained right hamstring.

Angel Pagan had an RBI double in the seventh and Posey hit a sacrifice fly as the Giants added insurance.

San Francisco third baseman Eduardo Nunez got hit by Miller’s 91 mph fastball in the left ribcage area but stayed in the game in the bottom of the sixth after an athletic trainer and Bochy checked on him. He is expected to be fine to play Thursday.

Arizona dropped just its fifth game in the last 16 at AT&T Park.

FOR THE BIRDS

A few pigeons camped out a few feet in front of the batter’s box in fair territory and never went away even as some players and coaches tried to shoo them.

“I was amazed, first of all that they didn’t move,” Diamondbacks manager Chip Hale said. “They weren’t scared of anything, and a couple of times when the ball was put in play, it didn’t bother the fielders. So it was pretty impressive.

“We don’t really work on that in spring training.”

TRAINER’S ROOM

Diamondbacks: Arizona optioned RHP Vicente Campos to Reno to make room for Miller’s return to the rotation.

Giants: CF Denard Span was out of the lineup after leaving Tuesday night’s loss in the seventh inning with a stiff neck. … RHP Jake Peavy was still sore a day after receiving several shots of cortisone in his back.

UP NEXT

Diamondbacks: LHP Robbie Ray (7-12, 4.28 ERA) pitches against Colorado at Coors Field having gone 2-1 with a 1.50 ERA with 29 strikeouts and seven walks in his last four starts.

Giants: RHP Jeff Samardzija (11-9, 4.00) pitches the opener Thursday against his former Cubs team in Chicago for the highly anticipated four-game series against the NL Central leaders. “It’s critical. I don’t know if it’s quite make-or-break,” Bochy said.