Jesus Sanchez also went deep and Jesus Aguilar had two hits for the Marlins, who will attempt to complete their second three-game sweep of the season against Washington on Wednesday.
Rojas' shot in the fifth inning put Miami ahead 1-0 when he drove starter Joan Adon's fastball over the wall in left field for his second homer of the season.
The Marlins' longest-tenured player, Rojas has struggled early this season and began Tuesday with a .190 batting average. He raised it 21 points with his three-hit performance.
''I need to be able to relax a little bit more and let the other guys in this clubhouse, playing baseball for a long time, actually be part of what we want to do,'' said Rojas, in his eighth season with Miami.
Sanchez made it 2-0 with his drive off reliever Steve Cishek in the sixth. The homer was Sanchez's fourth, ending a drought going back to April 21.
Miami starter Cody Poteet retired the first 10 Nationals batters until Juan Soto's one-out single in the fourth. In his first start of the season after eight relief appearances, Poteet pitched 4 2/3 scoreless innings. He allowed one hit, walked one and struck out four. Poteet extended his scoreless streak to 19 2/3 innings from his six previous relief outings.
''I tried to keep it simple, not thinking too much and trusting myself out there,'' Poteet said. ''Obviously, amazing hitters every night that you're facing, so gaining that ability to trust my stuff is huge.''
Anthony Bender (1-3) relieved Poteet and threw one scoreless inning. Four additional Miami relievers combined to get the final 13 outs.
With Poteet adapting to a new role, Marlins manager Don Mattingly had him on a limited pitch count. Poteet exited after throwing 54 pitches.
''That was kind of the end of it no matter what,'' Mattingly said. ''I couldn't ask for more.''
Washington reliever Erasmo Ramirez's two errors and a throwing error by first baseman Josh Bell helped Miami score twice in the seventh. Ramirez misplayed Erik Gonzalez's sacrifice bunt attempt and then made an errant pickoff throw that got past Bell and scored Rojas from third. Gonzalez sprinted toward third and Bell's throw eluded third baseman Maikel Franco, allowing Gonzalez to score.
''In those situations we're trying too hard and create something that's not there,'' Nationals manager Dave Martinez said.
Washington trimmed the deficit on Bell's sacrifice fly in the eighth before Jacob Stallings' RBI single in the bottom half gave the Marlins another four-run advantage.
Adon (1-7) was lifted after 4 2/3 innings. The right-hander allowed one run, five hits, struck out two and hit a batter with a pitch.
As Bender took his warmup tosses in relief of Poteet, the alarm system at loanDepot Park went off repeatedly and caused a five-minute delay. Spectators immediately were informed that the system malfunctioned, resulting in the false alarm.
Marlins: OF Bryan De La Cruz sustained a bruised right forearm and left after getting hit by a 96 mph fastball from Adon in the fourth. ... LHP Richard Bleier (undisclosed injury) could soon throw a bullpen and progress to a rehab outing.
RHP Josiah Gray (4-3, 4.34 ERA) will pitch the series finale for the Nationals on Wednesday against RHP Pablo Lopez (4-1, 1.05).
More AP MLB: https://apnews.com/hub/MLB and https://twitter.com/AP-Sports
Copyright 2023 STATS LLC and Associated Press. Any commercial use or distribution without the express written consent of STATS LLC and Associated Press is strictly prohibited.