San Francisco has won four of its last six meetings with its old rival, small consolation in a disappointing season that has come after two World Series titles in the last three years.
Buster Posey doubled to open the San Francisco second, Hunter Pence was hit by a pitch and Pablo Sandoval singled to load the bases. Abreu then delivered a one-out triple that gave the Giants a 3-0 lead.
After the Dodgers cut the deficit to one in the top of the fourth, Sandoval hit a two-run homer in the bottom half of the inning.
Barry Zito made what was likely his final start for the Giants and picked up the win with a five-inning effort. San Francisco is expected to take advantage of a clause in Zito's contract that allows the team to buy him out for $7 million.
Zito (5-11), the 2002 Cy Young Award winner, allowed a run on four hits. Sergio Romo gave up a two-out double in the ninth before collecting his 37th save. Ricky Nolasco (13-11) endured the loss, surrendering six runs on eight hits in 5 2/3.