Luis Cruz put Los Angeles in front with a three-run homer in the sixth Friday and the Dodgers ended a four-game losing streak by downing St. Louis 8-5.

Los Angeles moved within a game of the defending World Series champion Cardinals for the second wild card berth in the National League.

Solo homers by Yadier Molina and Matt Carpenter in the second and a two-run blast by Matt Holliday in the third combined to give St. Louis a 4-3 lead.

That advantage disappeared, however, when Cruz hit his homer in the sixth. Adrian Gonzalez expanded the Dodgers’ cushion to 8-4 in the seventh with a two-run double.

The comeback made a winner out of reliever Shawn Tolleson (2-1), who walked one over 1 2/3 innings as the third of six Los Angeles pitchers.

Rookie Trevor Rosenthal (0-2) put two runners on in the sixth and became the losing pitcher when Edward Mujica gave up the home run by Cruz.