Through injuries and slumps, demotions and disappointments, Dansby Swanson and Adam Duvall got ready for the big moment.

When it arrived, they were ready.

Swanson hit a tying double with two outs in the ninth inning and Duvall delivered a two-run single as the Atlanta Braves rallied past the St. Louis Cardinals 3-1 on Sunday to take a 2-1 lead in the NL Division Series.

"They never quit. They never give up," Braves manager Brian Snitker said. "The heart and desire and will is unbelievable in those guys."

Atlanta had managed just four hits off Adam Wainwright and Andrew Miller before breaking through against closer Carlos Martínez. With runners on the corners, Swanson tied it at 1 with a drive off the wall in left.

Swanson pumped his arms as he celebrated after his third hit of the game . He came through after an intentional walk to Brian McCann — Swanson's .187 batting average with runners in scoring position was the lowest in the majors this year among qualified players.

"I love Dansby in those situations. I always have," Snitker said. "That kid lives for that moment."

Watching the inning develop, Swanson said he thought he might get a chance to bat in a big spot.

"In those situations, you just try and breathe and relax," said Swanson, who missed the playoffs last year because of an injured left hand. "It's easier said than done."

Duvall, who entered in the eighth, then hit a liner into center field to put the Braves ahead to stay. It was his second big hit of the series after he connected for a pinch-hit homer in Atlanta's 3-0 victory Friday.

"I'll be ready whenever they need me," said Duvall, who spent much of the year with Triple-A Gwinnett.

Game 4 is Monday at Busch Stadium. Atlanta needs one more win to advance to the NL Championship Series for the first time since 2001.

This is the first time the Braves have led a postseason series since they were up 2-1 on San Francisco in the 2002 NLDS. They lost the final two games that year.

"History, we don't really play into that. This is now," Swanson said.

St. Louis wasted a terrific performance by Wainwright, who pitched 7 2/3 innings of four-hit ball in his first postseason start since 2014. The 38-year-old Georgia native and former Braves draft pick struck out eight and walked two.

In the age of bullpens taking over in October, Wainwright and Mike Soroka locked up in an old-fashioned pitchers' duel. But the relievers ultimately decided the game.

"We were one out away and that is exactly what playoff baseball is all about," Wainwright said. "Just crazy stuff happens."

Wainwright departed after he walked Ozzie Albies on his 120th pitch, loading the bases in the first playoff game in St. Louis in four years. He got a big hug on the mound from catcher Yadier Molina and the sellout crowd of 46,701 saluted Wainwright with a standing ovation as he walked to the dugout.

Miller then came in and retired Freddie Freeman on a flyball to center, preserving a 1-0 lead.

But Martínez was hit hard for the second time in the series. He allowed three runs before he closed out St. Louis' 7-6 victory in Game 1.

"There were some pitches that didn't go where they were supposed to go," he said through a translator.

After Atlanta grabbed the lead, Mark Melancon worked the ninth for his second save of the playoffs. Paul Goldschmidt doubled with one out, but Marcell Ozuna struck out looking and Molina lined out to end the game.

"Being able to compete in a game like that is amazing," Swanson said.

The 22-year-old Soroka was almost as good as Wainwright, pitching seven innings of two-hit ball in his postseason debut.

St. Louis jumped in front when Ozuna doubled in the second, advanced to third on Molina's grounder and scored on Matt Carpenter's sacrifice fly .

After Soroka departed, the Cardinals threatened in the eighth. But pinch-runner Harrison Bader was caught trying to steal third ahead of José Martínez's pinch-hit single, and Sean Newcomb retired Dexter Fowler to end the inning.

"I thought it was a good time for me to go," Bader said. "You just stay on the aggressive side and unfortunately it didn't work out."

OZZIE AND WHITEY

Hall of Fame shortstop Ozzie Smith threw a ceremonial first pitch to current Cardinals shortstop Paul DeJong. Hall of Fame manager Whitey Herzog also was on the field before the game after he had a minor stroke last month.

UP NEXT

Dakota Hudson will start Game 4 for the Cardinals. The rookie right-hander is making his postseason debut after going 16-7 with a 3.35 ERA this season.

Snitker said he wasn't ready to announce his starter for Game 4. One possible option is bringing back Dallas Keuchel on short rest after he pitched 4 2/3 innings in series opener Thursday.