SAN FRANCISCO (AP) - A little bit of luck helped the San Francisco Giants slip past the Los Angeles Dodgers. Gorkys Hernandez scored the go-ahead run on a balk as the Giants beat the Dodgers 6-4 on Friday night. The Giants rallied from a 4-2 deficit, scoring four runs in the bottom of the seventh inning. The Dodgers were 10-1 when leading after the sixth going into Friday night. Evan Longoria and Brandon Crawford homered for the Giants. Hernandez scored the go-ahead run when Dodgers reliver Pedro Baez slipped at the end of his delivery, firing the ball into the grass near the pitcher's mound during Joe Panik's at-bat. "It happens occasionally," Giants manager Bruce Bochy said, "You take it though. That's a big run there. You don't you see it very often, but it happens." Said Hernandez: "It's crazy." Hernandez and pinch-hitter Kelby Tomlinson had consecutive run-scoring singles with one out in the seventh off Tony Cingrani (0-1). "He tried to make a pitch and tripped," Dodgers manager Dave Roberts said. "The ball fell out of his hands and stayed in play. It's a freak thing." Dodgers starter Hyun-Jin Ryu gave up two runs in 5 2/3 innings of four-hit ball in which he struck out seven and walked none. The South Korean left-hander was in line for his fourth straight win when he left the game with a 4-2 lead. Giants starter Derek Holland gave up four runs in 3 1/3 innings. He's winless through five starts with his new team. Sam Dyson (1-0) pitched a scoreless seventh for the Giants. The bullpen combined for 5 2/3 innings of shutout ball. "The bullpen," Bochy said. "That's who saved us and gave us a chance to win." Ryu gave up solo home runs to Longoria (his fifth) and Crawford (his second). Dodgers third baseman Kyle Farmer had a career-high three hits. Hunter Strickland pitched a scoreless ninth for his sixth save. He struck out Yasmani Grandal looking for the last out to the chants of "Beat L.A."