With the score knotted 1-1, Adrian Gonzalez led off the 10th with a double against Craig Stammen (5-5) and Ramirez followed by belting a pitch off the wall in the left-center field gap, sending home the decisive run.
Andre Ethier tacked on an insurance run with a sacrifice fly as the Dodgers took a second straight from the Nationals.
Rookie Chris Withrow (1-0) earned his first major league victory with a scoreless ninth and Kenley Jansen notched his 11th save for second-place Los Angeles, which came into the contest trailing National League West-leading Arizona by 1 1/2 games.
Dodgers starter Zack Greinke tossed six innings of one-run ball in a no-decision.
Nationals counterpart Gio Gonzalez performed even better, pitching six shutout innings while striking out 11.
Roger Bernadina supplied Washington's only RBI.