Updated

Pittsburgh, PA (SportsNetwork.com) - Two decades of losing in the Steel City has given way to this: The Pittsburgh Pirates are one win away from the National League Championship Series.

Pedro Alvarez hit a go-ahead RBI single in a two-run eighth inning on Sunday and the Pirates beat the St. Louis Cardinals 5-3 in Game 3 of the NL Division Series.

In the playoffs for the first time since 1992, the Pirates took a 2-1 lead in the best-of-five series with Game 4 set for Monday afternoon in Pittsburgh.

Russell Martin also had an RBI single in the eighth after Carlos Beltran tied the game for the Cardinals with his second home run of the series in the top of the inning.

Beltran's solo homer off Mark Melancon -- the 16th postseason home run of his career, moving him past Babe Ruth for eighth all-time -- made it 3-3, bringing a dose of drama to a series that began with two blowouts in St. Louis.

Indeed, the eighth inning was a roller coaster.

After Beltran quieted the PNC Park crowd with his homer -- the right fielder knocked in all three St. Louis runs -- Andrew McCutchen picked them up with a leadoff double to left in the bottom of the eighth off Carlos Martinez (0-1).

Just as quickly, the mood turned again -- and then again.

McCutchen, trying to take third on Justin Morneau's grounder to shortstop Pete Kozma, was thrown out standing up. But Marlon Byrd walked, moving pinch-runner Josh Harrison to second, and Harrison raced home on Alvarez's single through the right side. Martin's hit to left after that scored Byrd.

Jason Grilli then retired three in a row after giving up a leadoff single to Matt Adams, earning his first career postseason save.

The Pirates have won two in a row to take the lead. They beat the Cardinals 7-1 in Game 2 on Friday after losing the series opener 9-1.

"Right now we're playing good baseball, pretty much like we have all year long," said Martin. "So ... the confidence level is high. And the stakes couldn't be any higher."

The Pirates will start right-hander Charlie Morton on Monday afternoon and the Cards will turn to righty Michael Wacha, who came within an out of throwing a no-hitter in his last start of the regular season.

Looking ahead, Cardinals manager Mike Matheny liked the chances the NL Central champions would be able to get over Sunday's loss.

"I've been very impressed how our club has bounced back whenever something hasn't gone exactly how we planned," Matheny said. "They have a short memory. Right now it hurts. They're going to sit on it for a little while. Tomorrow morning they'll be ready to go."

Byrd hit a two-run single and Martin also had two RBI for the Pirates, who got six innings from NL wild-card game winner Francisco Liriano. McCutchen had two hits and scored twice.

Liriano, who was 3-0 with a 0.75 ERA in three starts against St. Louis in the regular season, gave up a two-run Beltran single in the fifth and three hits overall. He walked two and struck out five.

Cardinals right-hander Joe Kelly came out with the bases loaded and one out in the sixth. Two of the three runs charged to the right-hander in 5 1/3 innings -- including one in the sixth -- were earned. He gave up five hits and four walks and had five strikeouts.

Kelly, who went 10-2 after the Cardinals moved him into the starting rotation in July, walked McCutchen to lead off the sixth and gave up a one-out double to Byrd. After intentionally walking Alvarez to load the bases, he was pulled for Seth Maness.

Martin sent the next pitch into deep center field to score McCutchen easily for a 3-2 Pirates lead.

"The quality of our at-bats has shown up the last two nights throughout the lineup," said Pirates manager Clint Hurdle. "We've given ourselves opportunities and chances, whether it be by a walk or a situation where you extend an inning. We've had some two-out RBIs. We're just playing a much better and solid offensive game. ... It's pretty simple."

Earlier, Byrd's single through the left side in the first inning scored McCutchen and Morneau to give the Pirates a 2-0 lead. Both reached base with two outs on a walk and a single then moved up on Kozma's throwing error.

Liriano retired the first seven Cardinals hitters before Kozma doubled in the third. Kozma later went to third on a wild pitch but Liriano escaped a bases- loaded jam when Matt Holliday flied out.

Beltran's two-out, two-run single in the fifth tied the game. Jon Jay and Kozma scored on the play after they reached base with no outs.

Game Notes

The seven players with more playoff home runs than Beltran: Manny Ramirez (29), Bernie Williams (22), Derek Jeter (20), Albert Pujols (18), Reggie Jackson (18), Mickey Mantle (18) and Jim Thome (17) ... The Cardinals were 11-3 in the games Kelly started during the regular season, a mark that included an eight-game winning streak between Aug. 1 and Sept. 6.