Paco Rodriguez (1-2) earned his first major league victory, getting three outs on 10 pitches. Brandon League worked the ninth to earn his 10th save in 12 chances.
The NL Central-leading Cardinals tied the game at 3 on David Freese's broken-bat RBI double and Pete Kozma's infield single in the sixth. Nick Punto made a diving stop behind third base, but he couldn't throw out Kozma.
The Dodgers took a 2-1 lead on Gonzalez's RBI double off Joe Kelly in the third. Gonzalez led off the fifth with his fifth homer, extending the lead to 3-1. He tied the score at 1 in the first with an RBI double.
Ellis (.309), Gonzalez (.316) and Punto (.340), who went 3 for 4, powered the Dodgers' offense from the top of the order while sluggers Matt Kemp and Andre Ethier combined to go hitless in seven at-bats. Kemp struck out twice, including once with runners on first and second to end the sixth. The duo was a combined 0 for 6 on Friday.
Los Angeles starter Ted Lilly allowed two runs and two hits in 5 1/3 innings in his first major league game since a 12-2 loss to Colorado on April 29. The left-hander struck out three and walked one in his third start of the year.
Lilly began the season late on April 24 after recovering from offseason shoulder surgery, then went on the disabled list from April 30 to May 20 with a strained right rib cage.
Cardinals starter John Gast left in the bottom of the second because of left shoulder tightness. He faced six batters, giving up one run and one hit. The rookie left-hander threw 25 pitches, walking two and striking out none.
Notes: Dodgers SS Dee Gordon snapped an 0-for-25 slump when he singled in the fourth. ... The Dodgers improved to 1,009-1,007-16 in the teams' all-time series. ... The Cardinals are undefeated in their last seven series (6-0-1) going into Sunday's finale.
Link to box score: Los Angeles 5, St. Louis 3
Link to game discussion at The Cardinal Nation message board