ST. LOUIS -- Through the season's first half, San Diego was slogging through one of the worst offensive seasons in Major League Baseball history.

Since the All-Star break, the Padres have been a different team, thanks in part to the guy who helped win Saturday night's rain-delayed game.

Jedd Gyorko belted a one-out grand slam in the top of the seventh inning, erasing a 5-4 deficit and lifting San Diego to a 9-5 decision over St. Louis at sold-out Busch Stadium.

Gyorko's homer was his eighth of the year and the third slam of his two-season career. It was also his 31st career homer, enabling Gyorko to supplant Mark Loretta (30) for most by a second baseman in club history.

"I thought I hit a pretty good pitch," Gyorko said of the 0-1 fastball by Kevin Siegrist. "He threw it down and in, but I was looking for it there. I got the bat head down."

San Diego (58-64) entered the All-Star break averaging less than three runs per game, but has scored 122 in the last 27 games, going 17-10. Only Pittsburgh (127) has plated more runs since the break among National League teams.

Cardinals pitching offered plenty of help in this one, issuing a whopping 10 walks. One of those came to catcher Yasmani Grandal just before Gyorko lined his homer off signage just above the left field wall.

"Good, patient at-bats," Padres manager Bud Black said of his hitters. "They laid off some tough pitches and swung at strikes."

It was a difficult loss for the Cardinals (65-57), which led 4-0 after two innings and regained the edge in the fifth inning on a two-out RBI triple by first baseman Matt Adams. They fell three games back of Milwaukee for first place in the NL Central but stayed a game ahead of San Francisco for the NL's first wild-card spot.

"We got some early offensive production," Cardinals manager Mike Matheny said. "It's hard to see that go away. Two really rough innings made for a bad day."

St. Louis exploded in its half of the second inning against rookie Jesse Hahn. Shortstop Jhonny Peralta and right fielder Oscar Taveras each produced RBI doubles, and third baseman Matt Carpenter knocked in two runs with a two-out double that bounced by sliding center fielder Abraham Almonte.

But Shelby Miller gave the runs right back in the third inning. Gyorko put San Diego on the board with a two-out RBI single and first baseman Jake Goebbert grounded a three-run triple just inside the first base line.

A two-out walk to right fielder Rymer Liriano, one of a career-high six Miller allowed in six innings, preceded Goebbert's big hit.

"You get a four-run lead, you don't go out and give up four runs," Miller said. "Unacceptable."

Miller left with a 5-4 lead, but Siegrist (1-3) couldn't hold it. The San Diego bullpen, which leads MLB with a 2.35 ERA, locked it down with three scoreless innings.

Padres left fielder Seth Smith went 3-for-4 with an RBI, closing the scoring with a two-out single in the eighth inning.

Making his 12th MLB start, Hahn gave up a career-high five runs and seven hits in 5 2/3 innings, walking one and striking out three. But the newly revived San Diego offense took him off the hook.

"We've been doing a good job lately of getting those timely hits," Gyorko summed up.

NOTES: St. Louis RHP Michael Wacha threw off a mound for the first time in two months Saturday. Wacha, who is 5-5 with a 2.79 ERA in 15 starts, went on the disabled list June 22 due to a stress reaction in his right shoulder. ... San Diego 3B Yangervis Solarte (oblique) returned to the lineup after a two-game absence, leading off. He was injured in the seventh inning Wednesday during the Padres' 5-3 win over the Colorado Rockies. ... The Cardinals inducted their inaugural class into the team's Hall of Fame on Saturday. The four men honored were OF Willie McGee, OF Jim Edmonds, SS Marty Marion and 3B Mike Shannon. Shannon is also the team's longtime radio play-by-play voice.