MILWAUKEE -- Yadier Molina simply wanted a sacrifice fly.
The Cardinals had taken a 4-2 lead in the eighth, and Molina came up with the bases loaded and one out.
"All the way through that at-bat I was thinking flyball," he said. "You never want to hit a ground ball there, never. I was just trying to hit a flyball to get that man in."
Molina sent a 1-2 pitch from Todd Coffey into the left-field stands for his sixth homer of the year to give the Cardinals an 8-2 lead.
St. Louis needed that big inning as Milwaukee scored four times in the final two innings, and had Prince Fielder at the plate as the tying run with two outs in the ninth. Ryan Franklin got him to ground out to end the game.
"We got touched up a little bit at the end, but we got the outs -- everybody got the outs -- when we needed it," St. Louis manager Tony La Russa said.
The Cardinals won for the third time in four games. They began the day trailing NL Central leader Cincinnati by seven games.
"From now on, we have to win, that's a rule," Molina said. "We can't go back. We've got to do it. We've got to win some games."
Mitchell Boggs (2-2) pitched 1 1/3 innings for the win.
Milwaukee starter Yovani Gallardo bounced back from three consecutive poor starts to pitch seven solid innings, but St. Louis erupted against three relievers.
With one out in the eighth, John Jay was hit by a pitch from Zach Braddock (1-2).
Jeremy Jeffress, one of the top prospects in the Brewers' system, was then summoned to make his Miller Park debut. The right-hander got Albert Pujols to hit what could've been an inning-ending double play, but it bounced off third baseman Casey McGehee's glove for an error.
"It was another winnable game but no execution when things are on the line," Milwaukee manager Ken Macha said.
Pedro Feliz hit the first pitch from Coffey for a single, making it 4-2. Molina's slam then gave the Cardinals what they thought was a comfortable lead.
"I didn't get the job done," Coffey said. "I get the job done out there, we win the game. I come in with the bases loaded I've got to get it done."
The Brewers pulled within 8-4 in the bottom half on an RBI single by McGehee and an RBI double by Alcides Escobar.
Hart hit his 26th and 27th home runs. Rickie Weeks hit his 26th for Milwaukee.
Hart's second homer brought the Brewers within 8-6 with two outs in the ninth off Franklin.
St. Louis starter Jake Westbrook pitched six innings, giving up two runs on five hits.
Gallardo had allowed 20 runs in 14 2/3 innings over his past three starts. The right-hander pitched seven innings, giving up two runs on four hits.
- It was Molina's second career grand slam. His other came on opening day this year in an 11-6 win over Cincinnati.
- Jeffress pitched a scoreless inning during his major-league debut last week in Cincinnati.
- For the second time in as many day games the Brewers hung two panels over a portion of right-field to diminish the effects of the daytime shadows at Miller Park. The roof was closed completely in the eighth as rain approached.
- It was the first run allowed by Braddock in his last 14 appearances, spanning 9 2-3 innings.
- After the game, the Brewers recalled INF Luis Cruz and RHP Brandon Kintzler from Triple-A Nashville.