Ramirez was greeted with boos by fans in Miami, where he starred for 6 1/2 years before being dealt to the Dodgers last month.
His run-producing single in the sixth came during a four-run Los Angeles uprising capped by Juan Rivera's two-run homer.
Ramirez completed the Dodgers' scoring with another RBI single in the next frame.
Clayton Kershaw (10-6) got the win with 6 1/3 efficient innings, yielding two runs on three hits while walking one and striking out seven for second-place Los Angeles, which entered the game trailing National League West-leading San Francisco by one game.
Miami's Mark Buehrle (9-11) took the loss, coughing up four runs on seven hits through six full innings.
Justin Ruggiano homered for the Marlins.
Celebrity Breakups and divorces of 2014 [PHOTOS]