ST. LOUIS — Dansby Swanson hit a tying double with two outs in the ninth inning and Adam 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.
Atlanta had managed just four hits off Adam Wainwright and Andrew Miller before breaking through against closer Carlos Martínez. With two outs and runners on the corners, Swanson tied it at 1 with a drive off the wall in left.
Swanson pumped his arms as he celebrated on second base 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.
‘‘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 as a pinch-hitter 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.
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.
‘‘They never quit. They never give up,’’ Braves manager Brian Snitker said. ‘‘The heart and desire and will is unbelievable in those guys.’’
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.
St. Louis wasted a terrific performance by Wainwright, who pitched 7⅔ 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 his first postseason start since 2014.
In the age of bullpens, Wainwright and Mike Soroka locked up in an old-fashioned pitchers’ duel. But the relievers ultimately decided the game. 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.
‘‘We were one out away and that is exactly what playoff baseball is all about,’’ Wainwright said. ‘‘Just crazy stuff happens.’’
Miller then came in and retired Freddie Freeman on a fly to center, ending the inning and preserving a 1-0 lead. But Martinez 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.
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.
Soroka, 22, 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.
Dakota Hudson will start Game 4 for the Cardinals. The rookie righthander will be making his postseason debut after going 16-7 with a 3.35 ERA this season.