PITTSBURGH — A strike away from ending his team’s longest losing streak in two years, Pittsburgh Pirates closer Tony Watson tried to get St. Louis pinch-hitter Matt Carpenter to chase a fastball up and away.

Instead, Watson’s fastball went right down the middle. Whatever chance the Pirates might have of reviving their playoff hopes may have gone along with it.

Carpenter drilled a solo shot to tie the game with two outs in the ninth and Randal Grichuk and Jhonny Peralta followed with homers of their own as the Cardinals rallied for a 9-7 win.

The Pirates have dropped eight straight and fell 5 ½ games behind St. Louis in the race for the second wild card in the National League.

“To serve up four late, it’s hard to swallow,” Watson said after blowing his third save since inheriting the closer’s role when Mark Melancon was sent to Washington at the trade deadline.

Pittsburgh had scrambled back from an early 5-0 hole to move in front with a four-run fifth inning that included Jordy Mercer’s two-run double to left. The bullpen kept the Cardinals in check and Watson quickly retired the first two hitters in the ninth and had Carpenter — who came in 2 for 17 against Watson — down 0-2 before everything changed.

“Matt Carpenter is a really good hitter, faced him a number of times,” Watson said. “Thought I could get it. Couldn’t locate the pitch … middle up is a pretty high zone for every major league hitter.”

Things quickly unraveled from there. Yadier Molina doubled, Grichuk sent a long drive to the seats in left to put St. Louis in front and Peralta completed Watson’s implosion by depositing a 2-0 offering into the right-field seats.

“Behind in the count 2-0, you’re not getting ahead of hitters,” Watson said. “When hitters see that, balls start flying out of the park, in the gaps.”

Carpenter’s homer was the 15th by a St. Louis pinch-hitter this season, a major league record. Molina finished 4 for 5, including a first-inning grand slam. Mike Mayers (1-1) tossed a scoreless eighth for the win, and Seung-Hwan Oh worked around a solo homer to Jung Ho Kang in the ninth for his 16th save.

Kang had two homers for Pittsburgh in his second game back from a stay on the disabled list but Watson’s stumble extended the team’s longest funk since a 10-game losing streak in 2011. An All-Star as a setup man in 2014, Watson has given up a career-high nine homers this season. The three he surrendered in the ninth matched his season total in 2015.

“It’s all about location, No. 1,” manager Clint Hurdle said. “He was much more efficient location wise last year than he is right now. We’ve got some guys that are not quite having the seasons they’ve had in the past. It’s part of the maturation process of being in the game.”

St. Louis raced to a quick 5-0 lead behind Molina’s first grand slam since 2012 and Matt Adams’ 436-foot homer in the second that reached the Allegheny River on the bounce. Pittsburgh, however, scrapped back.

John Jaso atoned for an earlier defensive miscue with an RBI single in the second and Kang homered in the fourth to make it 5-2. Matt Bowman entered for rookie Luke Weaver, pulled after four innings and 83 pitches, and quickly frittered the lead away. His wild throw to second on an attempted double play gave Pittsburgh life. Gregory Polanco followed with an RBI single, Andrew McCutchen scored when Brandon Moss couldn’t handle Matt Joyce’s line drive and Mercer doubled to the left-field corner to give the Pirates just their second lead in a week.

It didn’t last.

TRAINING ROOM

Cardinals: RF Stephen Piscotty was initially held out of the lineup to give his aching left wrist a breather. Piscotty took a pitch off the wrist on Monday. Postgame X-rays were negative and Piscotty doubled as a pinch-hitter in the eighth.

Pirates: Pittsburgh held C Francisco Cervelli out of the lineup a day after he experienced discomfort in his left hand trying to block a pitch.

UP NEXT

Cardinals: Mike Leake returns to the rotation after a stay on the disabled list while battling a case of the shingles. Leake is 9-5 with a 3.28 ERA in his career against Pittsburgh but is 1-2 with a 5.71 ERA this season.

Pirates: Rookie Jameson Taillon will face the Cardinals for the first time in the series finale. The 24-year-old has a 2.80 ERA over his last 10 starts and pitched six innings of one-run ball last week against Milwaukee.