SAN FRANCISCO -- Hanley Ramirez's daily chats with hitting instructor Manny Mota are already paying big dividends for the Dodgers.
Now it's even more clear why the Los Angeles front office didn't flinch when pursuing a deal for the high-priced slugger this week.
Ramirez hit a two-run homer in the 10th inning and the Dodgers beat the San Francisco Giants 5-3 on Friday night in a matchup of the top two teams in the NL West.
"It's why I'm here," Ramirez said. "Manny Mota spoke to me and told me, 'Don't try to do too much. Just do what you know how to do.' Every day he comes and talks to me. I have a lot to learn from him."
Two days after being acquired from Miami in a trade meant to boost the Dodgers' offense and playoff hopes, Ramirez went hitless in his first four at-bats against the Giants before homering to left-center on an 0-1 pitch from reliever Sergio Romo (3-2).
Ramirez's 15th home run of the season extended a stellar start to his Los Angeles career. The infielder slugger had three hits in the first two games with his new club and is batting .364 since the trade from the Marlins.
"Just another lethal bat in our lineup," catcher A.J. Ellis said. "That ball was crushed."
Ramirez also made a potential run-saving play in the field when he dove into foul territory to catch a throw from rookie pitcher Stephen Fife for a forceout following Matt Cain's attempted sacrifice bunt in the fourth.
It was exactly the type of performance manager Don Mattingly hoped for from Ramirez after the third baseman had some issues in Miami.
"Hanley's an intelligent guy," Mattingly said. "He's been easy to deal with."
Andre Ethier, who walked ahead of Ramirez's home run, had two hits and scored twice to help pull Los Angeles within two games of first-place San Francisco.
The Giants, looking to bolster their light-hitting offense, obtained veteran infielder Marco Scutaro from Colorado in a deal that was announced during the game.
"It's no secret we're looking for experience and depth," San Francisco general manager Brian Sabean said.
Even with their offense sputtering, the Giants didn't go quietly.
Kenley Jansen gave up back-to-back singles to Melky Cabrera and Buster Posey to open the bottom of the 10th. Jansen struck out the next two batters and then got Joaquin Arias to fly out for his 20th save.
"We needed that win," Ramirez said. "We have a couple months left and we're just going to go out there and keep winning series."
Shawn Tolleson (1-0) pitched one inning for his first major league win.
Los Angeles needed this one after getting shut out in three consecutive games here earlier this season.
The Dodgers got a stellar outing from rookie starter Fife and just enough from the bullpen until Ramirez's heroics in the 10th.
Fife was called up from the minors before the game to make his second career start and pitched into the seventh inning. He also helped end the Dodgers' 38-inning scoreless streak at AT&T Park when he doubled off Cain in the fifth for his first career hit.
Jerry Hairston Jr. followed with an RBI double and scored on Mark Ellis' single to give Los Angeles a 2-1 lead.
Before that the Dodgers had not scored at the Giants' waterfront ballpark since Sept. 11, 2011, including a series sweep earlier this season.
Los Angeles got to Cain again in the sixth when Ethier hit a leadoff double and scored on Loney's single.
Cain allowed three runs and nine hits over seven innings. The All-Star right-hander, who struck out two and didn't walk anyone, has only one win over his last six starts and was on the hook for the loss until San Francisco scored twice in the eighth.
The Giants' biggest problem isn't their pitching, however. That's why they made the deal for Scutaro. He was hitting .271 with four home runs and 30 RBIs in 95 games for the Rockies.
SS Luis Cruz has a 10-game hitting streak for Los Angeles. ... Giants 3B Pablo Sandoval is making progress and could return to the lineup as early as this weekend, according to manager Bruce Bochy. ... Dodgers LHP Ted Lilly threw a bullpen session and will pitch for Class-A Rancho Cucamonga on Sunday before the team decides what to do next with the 36-year-old pitcher. ... San Francisco backup catcher Hector Sanchez (left knee sprain) played seven innings for Triple-A Fresno and might see time at first base before getting activated from the DL. ... The Dodgers placed LHP Scott Elbert (elbow inflammation) on the 15-day DL. The move, which was made to open a roster spot for Fife, is retroactive to July 26. ... A fan ran onto the field and made it to home plate before being taken away by security in the middle of the fifth inning. ... Dodgers RHP Chad Billingsley (5-9) faces LHP Barry Zito (8-6) in Saturday's game, which was originally scheduled as a night game before being changed to 1:05 p.m. for television.