Garrett Cooper also homered and scored twice for Miami, which moved within 2 1/2 games of first-place Atlanta in the NL East.
Alfaro, the Marlins' catcher, was removed in the seventh inning as a precaution after Christian Vazquez's foul ball beaned him.
"Just getting past the baseball and just trying to make sure that he's good and not let him catch another foul ball," Miami manager Don Mattingly said of the decision to remove Alfaro.
Miami chased Boston starter Michael Kickham with a four-run third. Alfaro hit his first of two two-run blasts. Brian Anderson had a run-scoring single and scored from first on Lewis Brinson's RBI double to make it 6-1.
"We just pass the baton, we trust each other with anything," Brinson said. "There's no selfish player on this team. There's nobody that's here for their numbers."
Alfaro also went deep in the fifth, a 412-foot shot to left-center off Robinson Leyer.
Miami starter Trevor Rogers allowed one run on three hits, walked two, hit a batter and struck out three. He was lifted after 76 pitches after he took a hard-hit ball from Yairo Munoz off his back, retrieved it and threw Munoz out at first for the final out of the third.
"It tightened up on me right away," Rogers said. "I went to the trainer and he took care of it. It feels a lot better. Location was a big issue tonight so I was trying to lock it in and compete."
"To see him have the power to get the ball out -- opposite field here, you've got to kill it," Boston manager Ron Roenicke said. "And then he followed it with a base hit. Good swings all night from him."
Cooper hit a two-run homer to center in the first that snapped a 14-inning scoreless string by Red Sox pitchers.
Kickham (1-1) allowed six runs on seven hits in 2 2/3 innings.
Alex Verdugo had three hits, a walk and scored twice for Boston.
EVERY RUN MATTERS
A night after struggling offensively, the Marlins clogged the basepaths in the first five innings. The early scoring and Alfaro's second homer proved crucial after Martinez's blast in the seventh got the Red Sox closer.
"You know that team is a big hit or two away from being right back in the game," Mattingly said. "That's what it felt like that all night. They weren't going away."
Marlins: RHP Jose Urena (0-1, 7.71) allowed five earned runs in 4 1/3 innings against Philadelphia in his previous start.
More AP MLB: https://apnews.com/MLB and https://twitter.com/AP-Sports
Astros ace Justin Verlander says he needs Tommy John surgery
Houston Astros right-hander Justin Verlander is set to undergo Tommy John surgery, he said in an Instagram post Saturday.
MLB 2020 playoffs: Wild-card standings, playoff picture and postseason format
With Oakland becoming the latest to wrap up a postseason spot, we look at who hopes to join them and more.
Lure Brian Cashman from the Yankees? Why it could be Steve Cohen's first move as Mets owner
Attempting to nab the popular general manager from the crosstown rivals might not be as far-fetched as it sounds.
Familiar teams meet again as Mariners take on Padres
Despite being in different leagues, there has long been a familiarity between the San Diego Padres and Seattle Mariners, who continue a three-game series in San Diego on Saturday.
Lynn, Heaney meet up for third time as Angels host Rangers
Lance Lynn will try to continue one of the more remarkable streaks in the majors when the Texas Rangers face the Los Angeles Angels in the second game of their four-game series on Saturday night in Anaheim, Calif.
Rays aim to keep picking on Orioles
The Tampa Bay Rays took another step toward the American League East title Friday with a win over the host Baltimore Orioles. Now, they want to keep going.