SAN FRANCISCO -- St. Louis Cardinals shortstop Jhonny Peralta doesn't want to hear about AT&T Park being tough on hitters.

Not after what happened to him in the first inning Thursday afternoon.

Peralta smacked a two-run home run on a ball he thought was going to be caught, a pleasant surprise that gave the Cardinals a lead they never relinquished in a 7-2 victory over the San Francisco Giants.

"A lot of guys said you have to hit the ball pretty good here," the first-year National Leaguer said of the prospects of hitting a home at the Giants' home park. "I hit it pretty good, but I wasn't sure it was a home run."

The second consecutive win in San Francisco allowed the Cardinals to break even at 5-5 on their 10-game trip. The seven runs scored were one more than the six they had amassed in their previous six games.

In fact, Peralta's home run provided St. Louis its only first-inning runs of the 10-game trip.

"It was good to see that spark, whatever it is," Cardinals manager Mike Matheny assured. "Those have been hard to come by these days."

The Giants, meanwhile, fell for the 17th time in their last 22 games and 14th time at home in 17 outings. San Francisco completed a 2-8 homestand in which it lost series to the San Diego Padres, Cincinnati Reds and Cardinals.

Giants manager Bruce Bochy was dejected afterward.

"To come here and struggle like we did, it wasn't anything anyone could have foreseen," he said. "It's not acceptable."

Converted reliever Carlos Martinez (2-3) held the Giants to one run in season-high-tying five innings, escaping a bases-loaded jam in the fifth by striking out catcher Buster Posey with his final pitch of the game to preserve a 5-1 lead.

The Cardinals have won all four times Martinez has started this season. He struck out six in his five innings, surrendering five hits and one walk.

Cardinals relievers Sam Freeman, Seth Maness and Jason Motte combined to hold the Giants to one unearned run over the final four innings.

St. Louis jumped on Giants starter Madison Bumgarner (9-6) early, adding three runs in the fourth inning after Peralta's first-inning homer.

Martinez had the big hit of the fourth, a two-run single that followed an RBI double by center fielder Jon Jay.

"His energy is contagious," Matheny said of his 22-year-old pitcher. "He probably thinks he is (a good hitter). And he might be."

Peralta's homer, which came with third baseman Matt Carpenter aboard, was his team-leading 12th of the season. He later added a single.

Giants left fielder Tyler Colvin appeared to be camped under Peralta's high, deep fly about 30 feet in front of the fence. But in reality, he lost the ball in the afternoon sky, and it landed in the first row of the seats, fooling everyone.

"That was my reaction," Peralta said of an initial disappointment when he thought Colvin was going to catch the ball. "I knew I got a good swing."

Catcher Yadier Molina had three singles for the Cardinals, who out-hit the Giants 14-7. Jay (double and single) and Carpenter (two doubles) also had multiple-hit games for St. Louis.

Pinch-hitter Shane Robinson helped the Cardinals pad their lead in the sixth inning with an RBI triple.

Bumgarner was pulled for a pinch hitter after five innings, matching his shortest start since April 17. He gave up five runs, four earned, on six hits and three walks. He struck out six.

Center fielder Gregor Blanco, demoted to eighth in the batting order, had two hits, including a double, for the Giants, who despite the loss won the season series from the Cardinals, 4-3. Bumgarner had the team's only RBI, his eighth of the season, driving in Blanco from second base with a third-inning single.

Right fielder Hunter Pence and second baseman Joe Panik, moved up to first and second, respectively, in Bochy's new lineup, went a combined 1-for-7.

"We played awful baseball," Bochy concluded. "There's a time when you have to say enough is enough. That's where we're at."