LOS ANGELES (AP) A.J. Ellis drew a leadoff walk in the bottom of the 14th inning before the Los Angeles Dodgers loaded the bases with no outs. With slugger Adrian Gonzalez at the plate, the slow-footed Ellis knew he would have to hustle to score.
Gonzalez singled to deep left field, driving in Ellis for a 5-4 victory over the San Francisco Giants early Tuesday in the opener of a crucial series between the NL West's top two teams.
''There was a high level of panic,'' Ellis said. ''As soon as I saw (left fielder Nori) Aoki's number turn around and not facing me anymore I felt comfortable.''
Ellis entered the game as a pinch-hitter in the ninth and caught the final five innings.
''When you set the table for Gonzalez, you know he's going to find a way to come through,'' he said. ''That was a great team win. So many guys contributed.''
The first-place Dodgers' lead increased to 4 1/2 games over their second-place rivals after the longest game by innings between the teams since May 2, 1995.
''It stinks,'' Giants starter Jake Peavy said. ''We've got to win `em all against the Dodgers. We know that.''
San Francisco's Mike Broadway (0-1) started his first inning of relief by walking Ellis and then gave up consecutive singles to Jimmy Rollins and Chase Utley to load the bases. Giants reliever Yusmeiro Petit came on and Gonzalez hit his first pitch to deep left field, finishing off the 5-hour, 29-minute game that started in August and ended in September.
''We had our chances, they did too,'' Giants manager Bruce Bochy said, ''but the pitchers on both sides just found a way to get out of it all night.''
Chris Hatcher (2-5) pitched three innings for the win. The Dodgers used seven pitchers, with their much-maligned bullpen coming through in the clutch.
''It's a good feeling,'' Gonzalez said. ''Knowing we have (Zack) Greinke and (Clayton) Kershaw the next two days is even better feeling.''
The Dodgers won for just the fourth time in 13 games against the Giants this season, a day after getting no-hit by Jake Arrieta of the Chicago Cubs, the second time it happened in 10 days.
Both teams wasted numerous scoring opportunities as the game stretched into the wee hours and most of the 40,851 fans bailed.
''The atmosphere gets better in those situations,'' Ellis said. ''It reminds me of the minor leagues. That kind of dull buzz goes away and you hear individual things. We're glad we could deliver for these fans who stuck around.''
It became a battle of attrition for both teams.
The Dodgers sent Kershaw, their ace, to the plate with two outs in the 11th when they had no position players left. He grounded out to end the inning. The Giants ran out of position players in the 14th.
''It is September, so we might have been able to use September call ups,'' Gonzalez joked.
Marlon Byrd of the Giants tied the game 4-all in the eighth with an RBI-double in the right-field corner off Juan Nicasio. Byrd drove in three of the Giants' four runs.
The Giants have lost six of their last nine as they try to catch the Dodgers with a month left in the regular season.
Gonzalez and Andre Ethier homered for the tying and go-ahead runs in the sixth inning, giving the Dodgers a 4-3 lead.
Gonzalez's two-run homer, his 25th, tied the game 2-all and scored Rollins, who had a leadoff single. With two outs, Ethier homered to chase Peavy, who came in with a 6-0 record over his previous 10 starts at Dodger Stadium.
Giants: OF Angel Pagan (right patella tendinitis) was to be activated later Tuesday when rosters expand. ... INF Joe Panik (lower back inflammation) is in Los Angeles for the series and is set to begin a rehab assignment this week. ... RHP Tim Hudson (right shoulder strain) has been throwing bullpen sessions in preparation for his return from the DL. ... OF Hunter Pence (strained left oblique) is on schedule with his rehab and has been swinging the bat with no setbacks.
Dodgers: INF-OF Kike Hernandez went on the DL with a strained left hamstring, joining OF Yasiel Puig and INF Howie Kendrick, who are out with hamstring injuries. Hernandez got hurt trying to leg out an infield hit Sunday. He was hitting .308 with six home runs and 21 RBIs. ... RHP Joel Peralta (right neck sprain) is expected to come off the DL on Tuesday.
14th INNING STRETCH
The remaining fans jumped to their feet and sang along during the 14th-inning stretch. Veteran organist Nancy Bea Hefley is taking this homestand off, but she typically departs after the seventh-inning stretch. Her replacement stayed, providing rare live music for the singalong.
The Dodgers improved to 6-7 in extra-inning games this season, while the Giants fell to 5-4. It was the Dodgers' longest game since a 14-inning loss to the Washington Nationals last Sept. 5. It was San Francisco's longest game since a 16-inning loss to the New York Mets on July 8, 2013.
Giants: LHP Madison Bumgarner (16-6, 2.97 ERA) has eight career wins at Dodger Stadium, most by a Giants pitcher since Juan Marichal went 14-11 here during his career. Bumgarner is 2-0 with a 1.31 ERA in three starts against the Dodgers this season - all against Clayton Kershaw.
Dodgers: Greinke (14-3, major league-leading 1.61 ERA) is 6-0 with a 2.28 ERA in eight career starts against the Giants while holding opposing hitters to a .231 batting average. He is 7-1 at home this season.