When Cardinals rookie Marco Gonzales first started warming up early in Friday’s game, he was preparing to rescue another starter. When he warmed up in the middle innings, he was set to protect the bullpen from bulk innings. When finally he got into the game late, his assignment was the simplest of them all.

All he had to do was save the team from disaster.

No pressure, kid.

A leak in the eighth inning cost the Cardinals their three-run lead and put them on the precipice of a tie atop the National League Central division. The host Arizona Diamondbacks rallied to knot the game, 6-6, wiping out the Cardinals’ burst of offense and five intriguing innings from Michael Wacha. One more misstep and the Cardinals would have two games to play, a tie with the surging Pittsburgh Pirates to hold and a wild-card berth to avoid. Onto that tightrope, balanced between one step closer to clinching and one steep fall, strode Gonzales.

He pitched a scoreless ninth inning, pitched around a walk and an error and struck out a batter for the final out with the winning run at second base. Gonzales’ essential zero preceded Jhonny Peralta’s game-winning RBI single in the 10th inning and a 7-6 win at Chase Field.

“When you pull one out like that, it gives you confidence and hopefully some momentum,” Gonzales said. “A win like this is huge, huge for everybody.”

Matt Adams opened the top of the 10th inning with a double off the tip of Brett Jackson’s glove in right field, and his pinch-runner, Daniel Descalso, scored for Peralta’s third RBI of the game. Peralta had the bases-loaded double that first put the Cardinals ahead in the sixth inning and the go-ahead single that won it for them in the 10th.

Before Wacha threw the first pitch of his last audition to be a playoff factor, the Cardinals had an idea that Pittsburgh would keep pace with them. The Pirates-Reds game in Cincinnati was on the crystal-clear, large television in the visitors’ clubhouse at Chase Field. The Cardinals watched as Pittsburgh took a 3-1 lead it would not lose. Manager Mike Matheny, true to his resolution to avoid the Bucs’ score this weekend, did not take a peek.

“I’m the outlier,” he said

The Cardinals rallied from a 0-2 deficit early Friday and conjured a run late for the win to shave their magic number to two with two games to play. They can clinch as early as today with a win in Arizona and a Pittsburgh loss to Cincinnati. There will be champagne in the building. A misstep, however, like the one that happened against setup man Pat Neshek in the eighth inning, and the Cardinals would tumble into a tie for the division title. If the two teams finish Sunday’s games still tied, there will be a one-game tiebreaker Monday at Busch Stadium. The winner would advance to the National League division series, and the loser would have to play in the winner-take-all NL wild-card game Wednesday.

The Cardinals have secured home-field advantage for that game, if they slip into it.