Hanley Ramirez produced the kind of magical moment Friday night that the Dodgers envisioned when they inherited the $38-million remaining on his contract.

The capacity crowd at AT&T Park fell silent as Ramirez launched a 10th-inning slider from Sergio Romo into the left-field stands for a two-out, two-run home run that lifted the Dodgers to a 5-3 victory over the San Francisco Giants. The home run, Ramirez's first with his new team and 15th of the season, moved the Dodgers to within two games of the first-place Giants in the National League West.

"It's why I'm here — to win every day," Ramirez said.

The recently acquired three-time All-Star's homer was reminiscent of the kind of drama routinely produced by another Ramirez — Manny — after the Dodgers acquired him in a deadline deal four years ago. And it emphasized that these weren't the same Dodgers who visited San Francisco last month.

Those Dodgers didn't have Matt Kemp, who was sidelined by a strained left hamstring. Those Dodgers lost Andre Ethier to a strained rib-cage muscle. Those Dodgers were swept in three games and didn't score a single run in the series.

After the game-winning homer cleared the fence Friday, the Dodgers dugout exploded as Ramirez rounded the bases. He turned toward the dugout and gestured, as if to ask, "Did you see it?"

Said catcherA.J. Ellis: "It's unbelievable. The ball was crushed. It's just a different sound when it's coming off his bat."