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.
Millions of Getty images now available for free via embed tool
Boston schools pull out free condoms over wrapping complaints