PITTSBURGH -- Ike Davis lost his starting job, but he isn't letting that get him down in the middle of his first pennant race.

Davis' pinch-hit, three-run home run in the eighth inning lifted the Pirates to a 5-2 victory over the St. Louis Cardinals on Tuesday night in a game in which Pittsburgh center fielder Andrew McCutchen (left ribcage discomfort) and first baseman Pedro Alvarez (left foot discomfort) left the game with what they said were minor injuries.

McCutchen said he left as a precaution and should be ready to play Wednesday against the Cardinals, but Alvarez's injury might be more serious.

Manager Clint Hurdle told Davis last weekend that he would no longer be the left-handed-hitting part of the Pirates' first base platoon. Davis was sent to the bench to make way for Alvarez, who has a major-league-worst 25 errors as a third baseman this season.

"It's all about winning at this point, you put everything else aside," Davis said. "My whole career has been pretty much starting, not starting, starting, not starting. I'm used to it. You just wait for you chance to help win a ballgame."

Davis connected with two outs off right-handed reliever Seth Maness (5-3) for his ninth home run of the season and third as a pinch hitter. Acquired from the New York Mets in an April trade, Davis is playing for a team in contention for the first time in his five-year career.

"It's fun," Davis said. "You feel a little extra energy when you come to the ballpark."

The Pirates snapped their two-game losing streak and moved within one game of San Francisco for the second National League wild card and 5 1/2 games back of Milwaukee in the NL Central. Both the Giants and Brewers were in action late Tuesday.

The Cardinals lost for the just the fourth time in their past 13 games fell two games behind the Brewers in the division race. Their lead over the Giants for the first wild card was cut to 2 1/2 games.

Left-hander reliever Tony Watson (9-1) got the win with two scoreless innings of relief, although he cost starter Gerrit Cole a victory by allowing two inherited runners to score.

Pirates left fielder Starling Marte reached base in all four plate appearances with two singles, a walk and a hit by pitch. Catcher Russell Martin had three hits, including a double. Third baseman Josh Harrison hit a solo home run leading off the fifth inning, his 12th of the season, to give the Pirates a 2-0 lead.

Pittsburgh first baseman Gaby Sanchez and Marte hit consecutive one-out singles in the eighth inning. After shortstop Clint Barmes flied out, Davis hit a drive to right-center field.

"(Maness) made a couple of nice pitches, but then he left one up and in the middle of the plate, and that's not going to turn out well," St. Louis manager Mike Matheny said.

Mark Melancon pitched a scoreless ninth for his 23rd save.

The Cardinals scored twice in the seventh inning to tie the score at 2-2.

Watson replaced Cole with no outs and runners on first and third, and he gave up a sacrifice fly to center fielder Jon Jay and an RBI single to rookie pinch hitter Randal Grichuk, who was recalled from Triple-A Memphis earlier in the day.

"The way Cole was pitching, we were going to have to steal a win, and we almost did," Matheny said.

Cole took a no-hitter into the sixth inning before giving up second baseman Kolten Wong's two-out double. In his second start since missing 46 days with a straight right lat, Cole was charged with two runs and three hits in six-plus innings. He finished with nine strikeouts and one walk.

"I thought my stuff was really good, but I just ran out of bullets in that seventh inning," Cole said.

Cardinals starter Lance Lynn also allowed two runs in six innings, surrendering six hits while walking three and striking out three. He won his previous three starts. The homer by Harrison was just the fourth allowed in his past 22 starts.

NOTES: St. Louis OF Shane Robinson was placed of the 15-day disabled list with a subluxation of the left shoulder, which occurred when he slid awkwardly while being caught stealing second base Monday night. OF Randal Grichuk was recalled from Triple-A Memphis. ... Cardinals LHP Marco Gonzalez is expected to be recalled from Memphis on Saturday to start in one of the games of the doubleheader against the Chicago Cubs at St. Louis. ... Cardinals RHP Adam Wainwright (15-8, 2.52 ERA) will start Wednesday afternoon against Pirates LHP Jeff Locke (5-3, 3.69 ERA) in the finale of the three-game series.