CINCINNATI — Sonny Gray was terrific for Cincinnati once again, especially at a key moment in the third inning.

The former Yankees pitcher — who was shipped out of The Bronx last offseason after struggling in the spotlight for two years — struck out 10 while pitching five scoreless innings, and the Reds held off the St. Louis Cardinals for a 2-1 victory Thursday night.

St. Louis had won five in a row to move into a virtual tie with Chicago for the NL Central lead. The Cubs had a chance to move in front again, but they lost 7-5 at Philadelphia on Bryce Harper’s game-ending grand slam.

The Cardinals wasted a prime scoring opportunity in the third when Paul Goldschmidt struck out looking with the bases loaded and two out. Gray, Robert Stephenson, Michael Lorenzen and Raisel Iglesias combined for a two-hitter.

“It was a big spot there,” said Gray, who’s 9-6 with a 2.92 ERA in 25 starts this season. “I fed him a lot of breaking stuff. I took a chance with a heater. It was a two-seamer that broke back just enough to catch the corner.”

Iglesias surrendered Kolten Wong’s check-swing RBI double in the ninth before retiring pinch-hitter Matt Wieters on a fly ball to center to finish his 24th save.

Nick Senzel and Eugenio Suárez each drove in a run for Cincinnati, which stopped a four-game slide.

Dexter Fowler had St. Louis’ first hit, a two-out single in the fifth. Gray then struck out Matt Carpenter to extend his scoreless streak to a career-high 18 innings.

“Sonny was great, and he left it all out there,” Reds manager David Bell said. “He worked hard against good hitters and shut them down. He gave us everything he had. Sonny has good self-awareness. He competed hard in a low-scoring game where every run counts.”

Gray walked three and hit a batter while throwing 97 pitches. Stephenson pitched the sixth inning and Lorenzen got five outs before Iglesias closed it out. Cincinnati finished with 15 strikeouts.

“That’s a tough recipe, 15 strikeouts and two hits,” St. Louis manager Mike Shildt said. “Their pitchers did a phenomenal job tonight.”

St. Louis had won Michael Wacha’s last 13 starts against Cincinnati, dating to September 2014. He had earned the win in 10 of them, including each of the last seven.

Wacha (6-6) extended St. Louis’ streak of consecutive scoreless innings to 22 before the Reds pushed across two runs in a fifth that he described as a “weird little inning.”

José Iglesias led off with a single and went to second when Tucker Barnhart was hit in the shoulder and head with a pitch. The runners moved up on Gray’s sacrifice bunt, and Iglesias scored on Senzel’s chopper fielded by second baseman Kolten Wong behind the mound with no time to throw out Iglesias at the plate.

One out later, Suárez drove in Senzel with a single to center.

“I felt good,” said Wacha, who fell to 13-2 in his career against Cincinnati. “I was down in the zone, getting weak contact and letting the defense make plays. That’s usually the way I pitch.”