SAN FRANCISCO — Perhaps there was a hangover from a stinging loss the previous night, or maybe the Cardinals’ heralded pitching prospect is on the verge of stardom.

Either way, from the San Francisco Giants’ standpoint, Sunday wasn’t pretty.

Alex Reyes pitched seven dominant innings in his third major league start, lifting St. Louis over San Francisco 3-0 to drop the Giants out of the top spot in the NL wild-card race.

The Giants fell a game behind the New York Mets, and the Cardinals closed within one game of San Francisco.

St. Louis got a two-run homer from rookie Aledmys Diaz to split this four-game series, winning the final two. The Giants finished this homestand 2-5 and have won just one series at AT&T Park since the All-Star break.

The Giants appeared to still be reeling from another blown ninth-inning lead in Saturday’s 3-2 loss.

“That hurt, not holding on, that’s a big swing,” Giants manager Bruce Bochy said of Saturday’s game.

San Francisco remained five games behind the Dodgers in the NL West, too.

The Giants were 0 for 6 with runners in scoring position.

“We created some chances today, we just couldn’t get them in, we couldn’t get the big hit,” Bochy said.

The Giants’ best chance came in the sixth, when Reyes’ errant throw on Brandon Crawford’s swinging bunt put runners at second and third with one out.

Reyes then struck out Hunter Pence and got Eduardo Nunez to fly out to left.

“He’s got a mid-to-upper 90s fastball, we weren’t able to square it up,” Crawford said.

Reyes (3-1), considered one of the majors’ best pitching prospects, hasn’t disappointed since he was called up from the minors on Aug. 9 after Michael Wacha went on the disabled list with shoulder discomfort.

Reyes gave up four hits, struck out six and walked two. The 22-year-old righty’s fastball was consistently in the mid-to-upper 90s mph.

“He’s got big stuff, a big fastball, 97, and he was commanding it pretty good,” Bochy said. “He has a plus changeup and breaking ball. We weren’t going to hit him.”

Seung Hwan Oh pitched a scoreless ninth for his 18th save.

Diaz hit his 16th homer in the third off Albert Suarez (3-4). The All-Star’s shot followed Matt Carpenter’s two-out double.

Suarez has allowed three runs or fewer in his first 11 career starts, but the rookie is winless in 10 outings (including six starts) since June 23.

“Today we lost, tomorrow is a new day and we’ll be ready,” Crawford said. “For the most part we played good baseball this series. If we keep doing that, we’ll be ok.”

LAW AND ORDER

With the Giants in desperate need of bullpen help, Bochy said right-hander Derek Law will be a ninth-inning option in a reshuffling plan going forward. Giants relievers have blown seven of 11 save opportunities this month. The team has already tied a franchise record with eight losses in games it led after eight innings.

Law has an 0.39 ERA in 26 outings since July 4.

“It’s time to tweak it a little bit,” Bochy said, “I’m not saying Law’s the closer, but with him and (right-hander Hunter Strickland), they’re going to be more in the mix in the eighth and ninth.”

TRAINER’S ROOM

Umpires: Plate umpire Brian O’Nora left the game after being struck in the mask by a foul ball of Hunter Pence’s bat in the second inning. He was diagnosed with a concussion by Giants team doctor Kenneth Akizuki. Second base umpire Laz Diaz called the rest of the game behind the plate.

“I’ve been doing this for 30 years and I’ve never been hit that hard,” O’Nora said.

UP NEXT

Giants: LHP Madison Bumgarner (14-9, 2.66 ERA) faces three-time Cy Young Award winner Clayton Kershaw in what will be the 11th matchup between the two southpaws in the series opener in Los Angeles. Bumgarner is 4-3 with a 4.44 ERA in nine starts since Aug. 2.