Andre Ethier added three hits and drove in a run for the Dodgers, who have won eight of their past 10 road games. Matt Kemp also drove in a run.
Rich Aurilia had two hits, including a home run for his 1,500th career hit. Fred Lewis and Emmanuel Burriss each added two hits and Bengie Molina drove in a run for the Giants, who finished 3-4 on their homestand.
Ray Durham drove in a run in the ninth.
Kemp and Ethier each drove in runs in the third to put the Dodgers ahead 3-1 and Loney's two-run double in the fifth gave the Dodgers a 5-2 edge.
Aurilia, who has 1,150 hits as a Giant, became the 565th player in major league history to reach the milestone.
Aurilia, an All-Star in 2001, has three home runs and 11 RBIs in his past seven games and ranks 26th in franchise history behind Bobby Thomson's 1,171 hits.
Dodgers starter Eric Stults couldn't get out of the fifth inning. He lasted four-plus innings, allowing two runs—one earned—on seven hits. He walked two and struck out four.
After giving up hits to Durham and Randy Winn to open the fifth, Stults was replaced by Brian Falkenborg, who retired all three batters he faced. Falkenborg (1-1) was credited with the win, a day after taking the loss in a Giants' comeback victory.
Takashi Saito allowed hits to the first two batters in the ninth, but came back to record his 16th save in 19 chances.
Giants starter Matt Cain (5-7) still hasn't beaten the Dodgers in seven starts. The right-hander gave up five runs and eight hits in six innings. He walked three and struck out five to fall to 0-4 against Los Angeles, the only NL West team he has yet to beat.