ST. LOUIS (AP) - Tyler O'Neill hit a solo home run with two outs in the 10th inning and the St. Louis Cardinals held their playoff position, rallying past the San Francisco Giants 5-4 on Saturday.

Yadier Molina also homered for St. Louis, which began the day 1 ½ games ahead of Colorado for the second NL wild-card spot. The Cardinals, who have seven games remaining, started three games behind Milwaukee for the top wild-card slot.

St. Louis won for the fifth time in six games. San Francisco has lost three in a row.

O'Neill hit his ninth homer, connecting off Mark Melancon (0-3) to give the Cardinals their 11th walk-off win of the season.

Carlos Martinez (8-6) pitched two scoreless innings.

Adam Wainwright, making his third start for St. Louis since elbow inflammation put him on the disabled list, gave up four earned runs on eight hits over 6 1-3 innings. He struck out six and did not walk a batter.

Molina tied it with a two-run homer off Dereck Rodriguez in the seventh inning. It was Molina's 19th home run, but only his second at home.

Aramis Garcia, who had four hits, gave the Giants a 3-2 lead with a two-run single off Wainwright in the seventh.

Rodriguez, the son of Hall of Fame catcher Ivan Rodriguez, gave up four runs on seven hits over six innings. He struck out two and walked one.

TRAINER'S ROOM

Cardinals: INF Kolten Wong was held out of the lineup as a precautionary measure. He left Friday's game with a sore hamstring and is listed as day-to-day.

"(He's) in pretty good shape," manager Mike Shildt said.

UP NEXT

RHP Miles Mikolas (16-4, 3.01) will face LHP Andrew Suarez (7-11, 4.24) in the final game of the three-game series on Sunday. Mikolas is 16-0 when receiving two or more runs of support. Suarez is 3-2 with a 2.67 ERA in his last five starts.