SAN FRANCISCO -- Jhonny Peralta smacked a two-run home run in the first inning Thursday, giving the St. Louis Cardinals a lead they never relinquished in a 7-2 victory over the San Francisco Giants.

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.

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.

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.

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

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, 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 manager Bruce Bochy's new lineup, went a combined 1-for-7.

NOTES: RF Hunter Pence, the Giants' new leadoff hitter, had a .733 OPS mark in his first 33 starts atop the lineup, his worst figure at any slot in the lineup in which he had at least 110 plate appearances. ... The Giants plan to activate 1B Brandon Belt from the disabled list before Friday's game against the San Diego Padres. Giants manager Bruce Bochy announced Belt will bat second, behind Pence, for the foreseeable future. ... Giants 2B Marco Scutaro was scheduled to make a fifth start for the club's affiliate in the Arizona Summer League on Thursday. Bochy said Scutaro would be sent to Triple-A Fresno to continue an injury-rehab stint on Sunday if all went well Thursday in Arizona. ... With prized prospect OF Oscar Taveras having rejoined the team Tuesday, the Cardinals sat out their three regular outfielders -- RF Matt Holliday (Tuesday), CF Jon Jay (Wednesday) and LF Allen Craig (Thursday) -- once apiece in the series. ... The Cardinals began the day having been involved in more shutouts (five) than non-shutouts (four) in the first nine games of their trip that ended Thursday. ... St. Louis will open a seven-game homestand Friday against the Miami Marlins, while the Giants kick off a five-game trip Friday in San Diego.