Tommy Pham's second solo homer off Hector Neris in the ninth inning tied it and the St. Louis Cardinals rallied from a 5-0 deficit to beat the Philadelphia Phillies 7-6 in 10 innings Wednesday night.

Jedd Gyorko hit a two-run homer and pinch-hitter Jose Martinez also connected for St. Louis.

The game went to extra innings after Freddy Galvis lined a double down the left-field line with two outs in the bottom of the ninth, but Odubel Herrera ran through a stop sign, around third-base coach Juan Samuel and was thrown out by 10 feet. He didn't even attempt to slide and was pulled from the game in a double switch.

Martinez led off the 10th with a double to right off Edubray Ramos (0-6). He advanced to third on a balk and scored when Ramos made a throwing error on a pickoff attempt at first base after Dexter Fowler was intentionally walked. Yadier Molina added an RBI single.