ST. LOUIS — It’s official: Giancarlo Stanton’s slump was short-lived.

Stanton homered twice, recording his 22nd career multihomer game, and Marcell Ozuna and Justin Bour also hit home runs as the Miami Marlins beat the St. Louis Cardinals 9-6 on Wednesday night.

Stanton went 3 for 4 and also walked while driving in four runs as the Marlins won their second straight. He has five hits in his last two games after starting Miami’s road trip in a 1-for-17 funk.

“Most of the time when he gets the barrel on it, it’s gone,” Ozuna said. “Like me, I try to do the same thing but double.”

Dustin McGowan (5-0) gave up a run in 1 1/3 innings of relief, while David Phelps and Kyle Barraclough each pitched a scoreless inning. AJ Ramos earned his 15th save in 16 attempts.

Miami starter Edinson Volquez allowed four runs in four innings, the third time in his last five starts that he failed to complete five innings. Volquez has not lost against St. Louis since April 27, 2014.

Volquez left the game with a sore left knee. He was expected to be re-evaluated Thursday, but is not scheduled to start again before the All-Star break.

“He was having something there that I guess he’s had in the past,” Marlins manager Don Mattingly said. “It flared up on him there and he just couldn’t pitch the way he needed to.”

Stanton lined a 1-1 pitch over the left field wall to give the Marlins a 1-0 lead in the top of the first.

Stanton’s second homer, a three-run shot, capped a five-run second. The Marlins, aided by a pair of Cardinals fielding errors by second baseman Matt Carpenter and first baseman Luke Voit, had just two hits during the frame. Four of the five runs given up by St. Louis starter Mike Leake (6-7) in the inning were unearned.

Ozuna drove in runs with a homer in the third and a double in the fourth. It was his third homer in his last four games.

Bour reached four times, with a pair of hits. Derek Dietrich had two hits for the Marlins and Dee Gordon scored twice.

Tommy Pham had an RBI double and scored on Stephen Piscotty’s single as the Cardinals scored three in the third. Pham’s two-run double in the sixth cut Miami’s lead to 8-6.

Leake went 3 2/3 innings in his shortest outing of the season. Just three of the eight runs he allowed were earned.

“Leake didn’t have his best stuff, but he pitched well enough to let us win,” Pham said. “That’s all you can ask from your pitcher. We have to do a better job of going out there and just playing great, mistake-free baseball.”

Four Cardinals pitchers combined for 4 1/3 innings of scoreless relief before Seung Hwan Oh gave up Bour’s solo homer in the ninth.

“Any time you’ve got multiple guys hitting home runs, you know that you’ve got people going up there with a good approach and doing the right thing,” Bour said. “It’s a good win.”

UPON FURTHER REVIEW

Miami appeared to score again in the third after Ozuna’s home run when JT Riddle was called safe at first base, negating an inning-ending double play and scoring J.T. Realmuto. Cardinals manager Mike Matheny successfully challenged the call at first base, keeping the score 7-0 Marlins.

“It was favored toward our direction, so we took a chance there,” Matheny said. “We’re talking a run, so if its 50-50 even and they (the replay staff) felt pretty good about it from the beginning.”

TRAINING ROOM

Marlins: P Brad Ziegler (right back strain) has started throwing from flat ground.

Cardinals: OF Dexter Fowler (right heel spur) took drills in cleats for the first time since being injured. … 2B Kolten Wong (right triceps strain) began a rehab assignment at Double-A Springfield on Wednesday.

UP NEXT

Marlins: RHP Tom Koehler (1-3, 8.33 ERA) has given up 15 runs in his last two starts, which lasted a combined 4 2/3 innings. He is 1-3 with a 7.62 ERA in five career starts against St. Louis.

Cardinals: RHP Michael Wacha (5-3, 4.16 ERA) has allowed one run in his last 12 innings, including six shutout innings against Washington on Saturday. He is 1-0 with a 5.40 ERA in three career starts against Miami.