The Brewers won their sixth in a row and they climbed within 1 1/2 games of St. Louis for the second National League wild card berth.
Washington owned a 2-1 lead heading into the ninth and Tyler Clippard (2-6) came on to try to nail down the win.
Norichika Aoki started the Milwaukee comeback by reaching on a bunt single, after which he went to second on a passed ball and took third on a fly out by Rickie Weeks.
Ryan Braun followed with a single that scored Aoki with the tying run. Braun stole second and scored what turned out to be the winning run on the double by Ramirez, who came in later in the inning on a throwing error by shortstop Ian Desmond.
Washington could not score after Adam LaRoche hit a two-run homer in the first, his 31st of the season.