On a night when shortstop Hanley Ramirez left the game with hamstring tightness, the Dodgers managed to put together at least one highlight.

Adrian Gonzalez lined a single into center in the 10th inning Thursday to lift the Dodgers to a 3-2 victory before a sellout crowd of 53,393.

The walk-off victory cut the Dodgers’ magic number to five.

Still, after the game, there was concern about Ramirez. The Dodgers said their most dynamic hitter during the second half left the game for “precautionary reasons” because of mild left hamstring tightness.

Nick Punto came out at shortstop to start the seventh inning.

Ramirez had been running very gingerly Thursday, and appeared as though he was trying to protect something when he ran the past few days.

He spent a month on the disabled list with a left hamstring strain earlier this season.

Carl Crawford led off the bottom of the 10th with a single to right and was sacrificed to second by Punto. Gonzalez then lined a single past shortstop Brandon Crawford, and Carl Crawford beat center fielder Angel Pagan’s throw to the plate to complete the walk-off.

The victory went to ex-Giant Brian Wilson, who pitched a scoreless top of the 10th.

The Dodgers thought they had won the game in the bottom of the seventh after A.J. Ellis blooped a single that managed to fall in front of the Giants' favorite awkward-looking right fielder, Hunter Pence.

Dee Gordon ran for Ellis and promptly stole second. Mark Ellis' bunt sacrificed Gordon to third, and Yasiel Puig drilled a double into the left-center gap to score Gordon and leave the Dodgers up 2-1.

The Giants missed a prime scoring opportunity in the eighth when they loaded the bases with one out. Ronald Belisario came on to face Pence, who had hit a solo home run in the second inning off Zack Greinke.

But Belisario induced Pence to bounce sharply to Juan Uribe at third. He stepped on the bag to get a force out before firing a one-hopper to Adrian Gonzalez at first, who deftly scooped it up to just nip Pence for the double play.

Greinke went six innings for the Dodgers, holding the Giants’ scoring to the Pence home run, a ball that just made it over the waist-high fence before the right-field foul pole.

Despite otherwise holding the Giants at bay, the right-hander labored. He walked two, gave up four hits and threw 107 pitches in his six innings.

After the Pence homer, the Dodgers tied the score in the bottom of the second off Matt Cain, helped along by some curious San Francisco fielding.

Andre Ethier was safe on what was ruled an infield hit that went off third baseman Pablo Sandoval. Uribe popped up but Marco Scutaro bobbled and then dropped the ball. He threw to second to get Ethier. That went as a force out. The Giants finally got the error they seemed determined to pick up when A.J. Ellis’ sacrifice bunt was thrown into center by Cain.

Mark Ellis then just beat out the relay for a double play as Uribe scored to tie it 1-1.