The Marlins have won four in a row while the Nationals have lost four straight.
With Ramirez's two-run shot off Washington starter Tim Redding (10-9) in the second inning, the Marlins shortstop became the second Florida player with 30 home runs and 30 stolen bases in a single season. Preston Wilson had 31 home runs and 36 stolen bases in 2000.
"I missed it last year by one homer," said Ramirez, who had 29 home runs and 51 stolen bases last season. "I don't want it to happen again so I just tried to take a deep breath and calm down and make a good swing."
First baseman Mike Jacobs has 32 home runs and second baseman Dan Uggla has 30 for Florida this season. The Marlins join the 2001 Oakland Athletics, who reached the mark with first baseman Jason Giambi (38), third baseman Eric Chavez (32) and shortstop Miguel Tejada (31).
"Power kills and they have it," Nationals manager Manny Acta said. "We have to put together hits to score a few runs and with one swing they put two on the board. They did it twice, and that was enough the way Josh Johnson was throwing the ball."
Cantu isn't far behind his fellow infielders. The third baseman sent a 1-2 pitch over the left-field scoreboard in the first inning for his second home run in two days and his 26th of the season to put the Marlins up 2-0.
"I guess it would be a great thing to hit 30," Cantu said. "It only takes four good swings. Hopefully, I can get it done."
Johnson (5-1) struck out a career-high nine batters, allowing two runs and six hits over six innings in his first appearance against the Nationals since August 2006.
"When you get in a groove, everything just kind of happens fast," Johnson said. "It's like the hitter comes up, you throw a pitch, done. Gets me another strikeout. Everything happens so quick."
Johnson, who returned July 10 for his first start since undergoing elbow ligament replacement surgery last year, has allowed three runs or fewer in 11 of his past 12 starts. Matt Lindstrom pitched a scoreless ninth for his fourth save in five opportunities.
Ramirez's homer gave the Marlins a 4-0 lead.
Elijah Dukes' two-run double off Johnson in the sixth inning cut Florida's lead in half, but it wasn't enough.
It has been a record-setting weekend at the plate for Florida. With Cantu's homer Friday night, the Marlins became the first team in major league history to have four infielders hit at least 25 home runs.
"Maybe we'll just keep adding on to that record," Manager Fredi Gonzalez said.
Redding, who has allowed a career-high 25 home runs this season, lasted six innings for Washington. He allowed four runs and five hits, including the homers from Ramirez and Cantu.
"I don't know what the approach is when facing them since they seem to have my number this year," Redding said. "I've faced them five times this year, I'll get them for a sixth time my last start of the year at home. They've been able to hit the ball around the ballpark on us as a team all year."
Gonzalez said the Marlins saved a scorecard from Friday night's game and Cantu's home run ball, but have not been contacted by Hall of Fame officials. "I'm sure at the end of the year, they'll get together with all four guys, maybe get something from them," he said. ... With one out and two on base in the first inning, Lastings Milledge fouled off seven straight pitches before Johnson finally struck him out. "That'll run the pitch count up," Johnson said.