ST. LOUIS (AP) Matt Holliday delivered the St. Louis Cardinals' first walk-off win of the season on Wednesday night and then was mobbed by his teammates.

''That's why I work out,'' he said, ''just in case something like that happens.''

The Cardinals scored twice in the bottom of the ninth and Holliday's RBI single with two outs was the difference in a 5-4 victory over the Philadelphia Phillies.

More from FoxSports

''It was an important game for us to win,'' Holliday said. ''We needed it and we need to win tomorrow to win the series. All games are important but this was one we needed to win.''

The Cardinals had lost five of their last six while the Phillies had won seven of eight and 10 of 12.

St. Louis rallied in the ninth against Phillies closer Jeanmar Gomez, who had converted his first nine save opportunities this season.

Pinch-hitter Kolten Wong led off with a walk. With one out, pinch-hitter Matt Adams doubled off the wall in right-center, a play that was reviewed to see whether it went over the fence.

''I thought it hit that flower bed out there and bounced back,'' Adams said. ''I saw the umpire's arms signal not a homer and I just had to get to second safely.''

After an intentional walk to load the bases with one out, Stephen Piscotty delivered an RBI infield single to tie the game and pitcher Carlos Martinez, pinch running for Adams, was out after rounding third.

Holliday then smacked a single through the left side of the infield to drive home the winning run.

''It's, I think, a great example of the fight in this team to not let a 4-0 lead get us down and to fight right back so that's a big win,'' said Piscotty, who had three hits and two RBIs. ''That's a confidence booster. We're going to hopefully keep that momentum going.''

Ryan Howard's seventh home run of the season, a three-run shot to center field in the fourth inning, gave the Phillies a 3-0 lead. That was the St. Louis native's 23rd homer in 67 career games against the Cardinals.

Odubel Herrera added a solo home run in the fifth, his third, to make it 4-0.

Cardinals starter Mike Leake, the team's big free agent addition of the offseason, entered the game with an 0-3 record and 5.83 ERA. He allowed four runs and four hits in five innings, his ERA rising to 6.03 after six starts.

The Cardinals scored three runs in the fifth with the help of two reviews.

Ruben Tejada led off the inning with a hit down the third-base line that was originally called foul but ruled a double after a 5-minute review. After a walk to Eric Fryer and pinch-hit single by Brandon Moss, Aledmys Diaz hit a single off the glove of shortstop Freddy Galvis that scored two runs. Fryer was safe at home on a close play that was reviewed, but not overturned.

Piscotty followed with an RBI single to score Moss and chase Phillies starter Adam Morgan, who allowed three runs and six hits in four-plus innings.

Phillies left fielder Tyler Goeddel made a catch at the wall to take a hit away from Jedd Gyorko to end the eighth inning.

''We walked five guys and three of them scored so the walks kind of hurt us,'' Phillies manager Pete Mackanin said. ''But like I said Gomez walked the leadoff guy, which I wasn't real happy about, but then he had a situation to get a ground ball. That's what we wanted him to do, and he gave us a ground ball that found a hole.''

TRAINER'S ROOM

Cardinals: OF Tommy Pham, out with a left oblique strain since opening day, began a rehab assignment at Triple-A Memphis on Wednesday night. He went 1 for 2 with a two-run single, walk and stolen base.

WHO'S ON FIRST?

Yadier Molina got a break from his catching duties on Wednesday and became the Cardinals' fifth starter at first base this season. Adams and Moss have started 11 games there, while Holliday has started four and Matt Carpenter has started one.

UP NEXT

Phillies: RHP Jerad Eickhoff (1-3, 4.15) has never faced the Cardinals. He is coming off a no-decision against Cleveland after allowing three runs and six hits over six innings.

Cardinals: LHP Jaime Garcia (1-2, 3.73) will make his eighth start and 10th career appearance against Philadelphia. He is 2-4 with a 3.27 ERA in his previous nine appearances against the Phillies.