ST. LOUIS -- Matt Carpenter hit a pair of home runs and Greg Garcia's bases-loaded walk capped a three-run rally in the ninth inning as the St. Louis Cardinals beat the Colorado Rockies 9-8 on Thursday night.

Carpenter went 4 for 5 with four RBIs after moving back to the leadoff spot. It was his first career multihomer game and he has a career-high 12 home runs this season.

Jhonny Peralta's two-run single off Rockies closer John Axford tied the game at 8-all and Garcia's walk scored Kolten Wong as the Cardinals recorded their seventh walk-off win of the season.

More from FoxSports

Axford (3-5) took his third loss in his last four outings.

Cardinals starter Carlos Martinez gave up five runs on 10 hits in five innings. Carlos Villanueva (4-3) earned the win.

The Cardinals snapped a two-game skid and improved to a major league-best 38-15 at home.

The Rockies are 3-15 at Busch Stadium since 2010 and haven't won in St. Louis since May 12, 2013.

The Cardinals ended a 22-inning scoreless streak when Wong's groundout scored Carpenter in the first.

Carpenter's 423-foot homer to dead center in the second gave the Cardinals a 4-1 lead and his solo shot in the fifth tied it at 5.

Nick Hundley's 442-foot home run to left in the sixth tied the game at 6. The Rockies capitalized on a pair of throwing errors by Kevin Siegrist to snap that tie with two runs in the eighth.

Nolan Arenado drove in his major league-leading 78th run in the first.

Rockies starter Chris Rusin erased one of his mistakes to Carpenter by hitting his first major league home run to tie the game in the fourth. Rusin, who gave up six runs in five innings, became the third opposing pitcher to go deep against Cardinals pitching this season.

TRAINER'S ROOM

Rockies: Left fielder Corey Dickerson left the game with a right rib contusion after diving while trying to catch Jason Heyward's triple in the fifth. His status is day-to-day.

Cardinals: Matt Holliday was placed on the 15-day disabled list after suffering a Grade 2 strain of his right quad during Wednesday's game against the Reds. It is the same injury that sidelined Holliday for 31 games earlier this season.

TEMPERS FLARE

Things got heated after Martinez hit DJ LeMahieu with a pitch to load the bases in the fifth. LeMahieu had words for Martinez while being escorted to first by Yadier Molina.

After being stranded at third when the inning ended, Arenado then exchanged words with Molina.

UP NEXT

Rockies: RHP Kyle Kendrick (4-11, 6.33 ERA) is making his 11th start on the road, where he is 2-6 with a 5.52 ERA.

Cardinals: RHP Michael Wacha (11-4, 3.27 ERA) is making a career-high 20th start and has gotten the most run support in the National League (6.16 runs a start).