Despite the setback, Los Angeles saw its magic number for clinching the National League West trimmed to four when second-place Arizona fell to Colorado.
The hit by Arias brought home one run and Pill's single delivered two more to put the Giants in front. Pence added a solo homer in the eighth.
Romo then retired the next three batters for his 34th save.
San Francisco starter Madison Bumgarner (12-9) got the win thanks to the Giants' rally. He gave up two runs on five hits in six innings. Kershaw lost for only the second time in his last seven starts.
Toddler uninjured after being knocked over by Obama family dog
Gal Gadot cast as Wonder Woman for 'Batman vs. Superman'