Matt Vierling walked to the batter’s box Thursday night as a pinch-hitter and the home-plate umpire pointed to first base. The Phillies had clawed back from a six-run deficit to get within one run when the Pirates decided they would rather face Ronald Torreyes — who was waiting to pinch-hit for Aaron Nola — than Vierling.

Soon Torreyes, who had never hit a pinch-hit homer, would be parading through the dugout wearing the team’s home run hat as teammates mobbed him in a rainy 12-6 win.

His three-run homer moved the Phillies within two games of first place with nine games remaining after Atlanta fell earlier in the day in Arizona. And it overcame the 6-0 hole dug by Aaron Nola that seemed deep enough to bury the season.

“It was very, very special,” Torreyes said. “Right now, every game matters a lot and we have to win every game.”

The Phillies, just like they did earlier this month when Nola handed them a 6-0 deficit, persevered. They scored five times in the third before Torreyes crushed a fastball into left in the sixth. Atlanta’s defeat concluded 30 minutes before the first pitch in South Philadelphia. A loss to the Pirates would have been brutal, since time is running out for the Phillies to gain ground.

But those playoff hopes felt a little more tangible when the Phillies responded. The Phillies will play the Pirates three more times this weekend while Atlanta plays four games in San Diego, one of which is the resumption of a suspended seven-inning game from July. If the Phillies can take care of business, they could arrive Tuesday to Atlanta in control of their postseason destiny.

“Hopefully, we just keep this momentum going,” manager Joe Girardi said.

The hole

Nola loaded the bases in the second inning, but was facing the opposing pitcher with two strikes and two outs. He was in a jam, but it looked relatively painless.

And then Connor Overton — a 28-year-old relief pitcher in his first major-league plate appearance — dropped a two-run bloop single into shallow left field that fell between Andrew McCutchen and Freddy Galvis. The next batter, Ke’Bryan Hayes, hit a three-run homer and Colin Moran started the third with a 432-foot homer to right. The hole was dug deep.

“He probably deserved much better than we got tonight when you start talking about the contact,” Girardi said as Nola’s lone hard hit ball in the third was the three-run homer. “But it happens in baseball. You can find holes and win some games. I thought Nola pitched a lot better than it showed.”

Nola found a way to give the Phillies six innings as he retired the final nine batters he faced. But that did not make up for dropping the team into a six-run hole in the final days of a playoff push. He has allowed 19 earned runs in 26 innings this month and his career ERA in September and October increased to 4.62.

“It’s frustrating, for sure. I let it get away from me when that ball dropped in,” Nola said. “The next guy hits the three-run homer. I let it get away from me too much, but I tried to stay in it as much as possible. I just wanted to put up as many zeroes as I could and keep the game at six and give the guys a chance. ”

Nola’s final start of the season is Wednesday night in Atlanta against a lineup much less forgiving than the one he faced Thursday. The Phillies need more from him next week.

“It’s obviously going to be big and be a big series,” Nola said. “They’re a couple games in front of us right now. Tomorrow is a big game, too. We have to take care of business tomorrow.”

The comeback

Didi Gregorius led off the third inning with a 438-foot homer to right, but it wasn’t yet clear if it would be enough to spark the offense or would just be one run in a lopsided loss. Two batters later, Nola walked and Odubel Herrera followed with a double. Nola scored on a passed ball and Herrera scored on a sacrifice fly. The six-run deficit was trimmed to three and it was easy to see that Gregorius’ homer wasn’t meaningless.

» READ MORE: Joe Girardi says Mike Schmidt’s praise of Bryce Harper is ‘fantastic’ and ‘pretty special’

“I always say that the first run is the toughest one to score,” Girardi said. “We had a game like this against the Cubs earlier this month and we were able to come back in that game and able to do it tonight.”

The Phillies scored twice more that inning on RBIs by McCutchen and Brad Miller and the comeback felt closer.

“They backed me up big time,” Nola said. “They came out swinging.”

Torreyes’ shot

Girardi used Vierling, who had two hits Wednesday, to pinch-hit for Andrew Knapp against left-hander Anthony Banda. When Vierling walked, Girardi had to use another pinch-hitter since Nola was on deck. He picked the right-handed Torreyes, who has not had an extra-base hit since Aug. 31 as his offense has tailed off since an early summer surge.

“I thought they might try to bring in the right-hander to face either one of them, but I was going to try and force their hand,” Girardi said. “Vierling has been swinging it well and Toe has been clutch for us all year. So I just took that chance.”

Girardi pulled the right strings. Torreyes jumped on the third pitch he saw — a low fastball — and sent it into the first row in left field. It barely cleared the fence, but it was far enough for the Phillies to keep their postseason dreams afloat.