In the fifth inning Sunday night with a runner on base and the game once again teetering toward squandered for the Cardinals, manager Mike Matheny marched out to the mound for an unusual visit with his starting pitcher.

The ESPN cameras, in Pittsburgh for “Sunday Night Baseball” for the first time in a generation, couldn’t translate the content of Matheny’s message.

The tone was hard to mistake.

“Classic Mike. Spitting the truth,” Miller said later. “He told me I had to find a way to get through it. … Pretty much told me, ‘You’re better than this.’”

He could say the same about the entire team.

The Cardinals got their runs early and eventually added to their lead later, but throughout Sunday’s 6-5 victory at PNC Park the pitching wobbled just enough to keep the lead in peril until the final out of the game.

Closer Trevor Rosenthal allowed one run and the bases to be loaded without an out in the ninth inning before pulling the sleight of hand necessary for a popup and a double-play ball. Rosenthal fielded a grounder and got the tying run trying to score and catcher Yadier Molina completed the double play that cinched the win and the salvage operation.

The Cardinals kept Pittsburgh, on the Sunday night national broadcast for the first time since 1996 and first time at PNC Park, from completing a sweep of the three-game series.

The win allowed the Cardinals to return to Busch Stadium after a 4-5 swing through three cities. Miller (5-2) survived for the win because the Cardinals capitalized on an error in the first inning for four runs, and Peter Bourjos delivered with a two-out RBI single in the eighth to key a two-run rally.

Then Rosenthal walked Clint Barmes on four pitches to load the bases in the ninth and put the winning run at second before gaining his 10th save of the season.

Matheny said it “felt like a walk-off win for us.”

“It’s an understatement that we needed to pull one out there,” the manager continued. “We’re looking to see what is the one thing that will get us clicking, able to pull off some wins without being as sharp as we’d like to be.”

Staked to a 4-0 lead by the timely hitting the Cardinals have craved for weeks, Miller initiated and invited trouble through most of his 5 1/3 innings. His start was freckled by four hits allowed, multiple visits to the mound and four walks, two of which came in the fifth inning.

He walked Ike Davis in the fourth inning and the next batter, .191-hitting Jordy Mercer, lifted a sloppy cutter into the seats to chomp the Cardinals’ lead in half. Mercer’s first homer of the season left the game at 4-2.