LOS ANGELES (KRON) — Play ball — the National League Division Series is set.

The San Francisco Giants will take on the Los Angeles Dodgers in the NLDS beginning Friday after the Dodgers defeated the Cardinals 3-1 in a down-to-the-wire wild card game.

Game 1, 2 and 5 will be played at Oracle Park, while Game 3 and 4 will be played in Los Angeles.

On Wednesday night, Chris Taylor hit a tiebreaking, two-run homer in the bottom of the ninth inning.

The sellout crowd of 53,193 hung on every pitch as the tension of a tie game built from the fourth inning on. Fans waved blue towels, futilely urging out the few balls launched into the outfield only to see them caught in a winner-take-all matchup between two of the most storied and successful National League franchises.

Cody Bellinger drew a two-out walk from T.J. McFarland and stole second in the ninth, when nearly every fan was on their feet, waiting to see if the defending World Series champions could pull off a win. Alex Reyes came in to face Taylor, who sent a 2-1 pitch into the left-field pavilion, triggering an explosion of cheers.

Tommy Edman dropped a one-out single into right off closer Kenley Jansen in the top of the ninth and stole second. Paul Goldschmidt took a called third strike and Tyler O’Neill went down swinging to end the threat.

Both teams had runners on in the sixth, seventh and eighth innings, but couldn’t push a run across.

Dueling aces Adam Wainwright of St. Louis and the Dodgers’ Max Scherzer struggled with their control early in just the second winner-take-all game in postseason history with two starting pitchers aged 37-plus. Wainwright is 40; Scherzer is 37.

They issued two walks apiece through the first three innings. Scherzer’s wild pitch led to a run in the first and he hit Harrison Bader in the fourth.

Justin Turner tied it at 1 in the fourth on a leadoff solo shot into the Dodgers bullpen in left. It was the first homer Wainwright has ever given up on a curveball in the postseason. Turner’s 13 postseason homers are the most in franchise history.

St. Louis led 1-0 when Edman scored on Scherzer’s wild pitch. Edman singled leading off, stole second base and took third when O’Neill fouled out to right.

Scherzer left with one out in the fifth after giving up a leadoff single to Edman and a walk to Goldschmidt. He paced the dugout with his hands on his hips. Former Cardinal Joe Kelly got out of the jam after Goldschmidt reached third on Kelly’s wild pitch.

Scherzer allowed one run and three hits, struck out four and walked three against his hometown team.

Wainwright gave up one run and four hits in 5 1/3 innings. He struck out five and walked two.

The Dodgers had Wainwright on the ropes in the third, loading the bases with one out. He was within one ball of walking in the tying run before Trea Turner broke his bat grounding into an inning-ending double play on a 3-2 pitch.