SAN FRANCISCO -- The complexion of the team's final three-city trip of the season took a sharp turn at the end, leaving the Cardinals part relieved and all satisfied to head home in better standing than they were when they left.
Dealing with a hemorrhaging rotation and oft-disappearing offense, the Cardinals, with a 7-2 victory over the Giants on Thursday, managed an even split of the 10-game trip. That meant that even on a road swing that included the team's worst offensive spell of the season, St. Louis actually gained ground on the first-place Brewers.
That lead is down to five games.
"We've had our hands full," manager Mike Matheny said. "To be able to go home 5-5 is a huge accomplishment, especially after losing a real tough one in L.A. that really could have changed the view of this whole trip. That's a real good trip."
The Cardinals salvaged the trip by winning the final two games in San Francisco, giving the club bookend series wins against the Rockies and Giants. In between was the forgettable portion in which the Cardinals were held to four runs in four games against the Dodgers.
"Winning these two and to win this series was a huge, huge thing for us," Matt Carpenter said. "If you look at it, the toughest part of our schedule is over. We still have to play good baseball, but it is lining up for us to take off."
Carpenter may be on to something. The Cardinals have knocked out all four of their scheduled three-city trips and have already taken on the two best teams in the National League's East and West on the road. Of St. Louis' next 15 games, 12 will come at home.
There, the club will look to build upon Thursday's offensive breakout in which they scored more runs in front of an AT&T Park crowd of 41,181 than they had in six previous games combined. Before that, the club had exploded for 22 runs in a three-game series at Coors Field.
This had the appearance of another mile-high affair.
The foundation was built during a pair of first-inning at-bats. Carpenter worked Giants starter Madison Bumgarner for a seven-pitch leadoff walk. Two outs later, Jhonny Peralta delivered a two-run blast. Peralta's team-leading 12th homer gave the Cardinals their first first-inning runs in more than two weeks.
"That was important," Peralta said. "I know we haven't done well scoring in the first inning."
"That kind of sets the tone," added Carpenter, "and then we were able to pile on as the day went on."
Though the Cardinals stranded 10, they went onto score in four different innings while Carlos Martinez complemented it all with the best start of his career.
A potential double play not turned by the Giants in the fourth opened the door for a three-run St. Louis inning. Jon Jay delivered an RBI double, after which starter Martinez helped his own case with a two-run single past a drawn-in infield.
Pinch-hitter Shane Robinson, batting in Martinez's place two innings later, contributed an RBI triple. The Giants' inability to turn two in the seventh again helped the Cardinals further pad their lead.
"We played some 'off baseball,' I guess you could say," Giants manager Bruce Bochy said. "We threw a couple double-play balls away, Bum wasn't quite on."
Both Bumgarner and Martinez lasted five innings, though it was the young Cardinals starter who was the sharper of the two.
Consecutive hits by the Giants pushed across a third-inning run, but Martinez otherwise drove in more with his one hit than he would allow. His athleticism was on show all afternoon, including in the fifth as he dived across the infield grass to make a play on Gregor Blanco's bunt. Blanco beat out the bunt anyway, and Martinez took a visit from the trainer as he was slow to get up.
He proved himself healthy with a pair of practice pitches and eventually finished off the inning by striking out Buster Posey with the bases full. Martinez, who threw 23 of his 88 pitches in that inning, gave several fist pumps as he returned to the dugout.
"It was the kind of situation that I like," Martinez said, with bullpen catcher Roberto Espinoza translating. "I love those tough situations where I face good hitters. I felt really good about getting the job done."
A member of a patchwork rotation until further notice, Martinez has now made four starts, all of which the Cardinals have won.
"It's huge that he's been able to step up," Matheny said. "He's been keeping us in games and has given us a chance to where we can come back and win a few of these. The kind of pitching that he's doing right now is winning pitching. It's a great evolution right now."
Jenifer Langosch is a reporter for MLB.com. Read her blog, By Gosh, It's Langosch, and follow her on Twitter @LangoschMLB. This story was not subject to the approval of Major League Baseball or its clubs.