SAN FRANCISCO -- Hector Sanchez had his wife and young daughter waiting in the parking lot. He had to do something to end the game.
"They've been waiting for 3 hours," Sanchez said. "My daughter has school tomorrow."
Hunter Pence had three hits for the Giants, who have won three of four.
"When you play hard and win in the last minute, it's a lot of fun," Belt said.
Brandon Crawford singled off Brandon League (0-1) with one out in the 12th and advanced to second on a groundout by Brandon Hicks. His bouncer deflected off third baseman Juan Uribe to shortstop Hanley Ramirez, who threw to first for the out.
But the Dodgers were unable to get the lead runner on the play, and it cost them.
Crawford went to third on a wild pitch and Sanchez hit a sharp one-hopper that glanced off the glove of diving second baseman Justin Turner and into center field.
"Every day is different," said Sanchez, who entered in the 10th inning. "I have to be ready for any situation. This is a great moment to enjoy."
Turner slammed his hand on the ground in frustration.
"I got lucky," Sanchez said.
Yusmeiro Petit (1-1) worked a scoreless inning for the win in a game that took 4 hours, 54 minutes and ended after midnight on the West Coast.
"It is frustrating. We had that game, man," Jansen said. "It's going to be us and them the whole year. They never quit. They keep playing hard."
Crawford also drove in a run for the Giants.
Turner's pinch-hit single in the seventh inning gave the Dodgers a 2-1 lead.
Uribe had three hits, including a home run and a double, and scored twice for the Dodgers, who had their three-game winning streak snapped. Yasiel Puig added two hits, including a triple.
Juan Gutierrez pitched 2 1-3 shutout innings with three strikeouts to keep the Giants close.
"It was a well-pitched game on both sides," Giants manager Bruce Bochy said. "We left a lot of runners stranded. When you don't come through you just have to keep fighting until you finally get a big hit."
Beckett allowed two hits over five scoreless innings in his second start of the season for the Dodgers. He walked five and struck out four.
"Most games that we play against these guys are going to be tight," Beckett said. "We just came up on the short end."
Lincecum gave up one run and five hits in five innings. He did not walk a batter and struck out five.
Los Angeles had the bases loaded with one out in the fourth, but Lincecum struck out Uribe and Tim Federowicz to end the threat.
The Giants also had the bases loaded in the fourth with one out. Beckett struck out Michael Morse swinging before retiring Crawford on a routine grounder.
Beckett walked the bases loaded with two outs in the fifth but got Buster Posey on a fly to center field.
The Giants also left the bases loaded in the 10th.
Dodgers 1B Adrian Gonzalez extended his hitting streak to 10 games. ... Giants LHP Jeremy Affeldt (right knee sprain) will be activated from the disabled list Wednesday. ... Giants 2B Marco Scutaro (lower back strain) continues to rehab and go through baseball activities. Bochy said a target date for Scutaro's return has not been set. "He has good days and days he has to back off a little bit," Bochy said. ... RHP Ryan Vogelsong (0-0, 8.00 ERA) pitches for the Giants on Wednesday. He is 4-3 with a 4.15 ERA in 20 games against the Dodgers. LHP Paul Maholm (0-1, 8.10) takes the mound for Los Angeles. He is winless in six career games at AT&T Park. ... Dodgers RHP Chad Billingsley cut short a bullpen session after eight pitches due to discomfort. He was sent to Los Angeles for an MRI. ... Dodgers LHP Clayton Kershaw (back) threw a bullpen session and manager Don Mattingly said the team is "plodding along with this. We'll see how far he can go. It seems to be going in the right direction." ... Lincecum struck out the side (in the third) for the first time this year.