"I was able to throw strikes and be in the zone," said Masterson. "Just continued progress of where we've been. I was able to repeat my delivery for the most part and throw the ball over the plate."
Closer Koji Uehara came on for the fourth and recovered from a leadoff double, retiring the next three batters, including two strikeouts.
Hanley Ramirez (RBI double) helped the Red Sox during a two-run rally in the bottom of the third.
After resting for the last three days with general soreness, Shane Victorino returned to the lineup and played four innings, going 0-for-2 with a walk.
Righty Matt Andriese made the start for the Rays, giving up two hits and two runs over 2 2/3 innings. Right fielder Kevin Kiermaier led off and went 1-for-3.
In the seventh, Garin Cecchini belted a two-run double to right center field to give Boston a 4-0 lead.
The Rays finally cracked the scoreboard in the eighth, as Logan Forsythe roped a leadoff triple and scored on a passed ball.
Up next: Joe Kelly draws the start in the first of two rivalry matchups with the Yankees this spring. The contest in Tampa is set for 1:05 p.m. ET, and the game will air on MLB.TV. Mookie Betts, Christian Vazquez, Allen Craig and Daniel Nava are on the trip. Craig Breslow, Brandon Workman and knuckleballer Steven Wright will see action out of the bullpen.
Ian Browne is a reporter for MLB.com. Read his blog, Brownie Points, and follow him on Twitter @IanMBrowne. This story was not subject to the approval of Major League Baseball or its clubs.