Castillo then led off the winning rally with a single to left, moved to second on a passed ball and used his speed to scoot to third on a medium-range flyout to center by Allen Craig.
Shortstop prospect Deven Marrero won it with a two-out single off the Green Monster.
"It turned out to be a good play," said Castillo. "I'm always kind of anticipating that kind of thing to happen. When you have a man on third in a big situation, you hope you can make a play like that and execute it. Fortunately it went our way."
Castillo's primary position is center field. But if he's to earn a spot on Boston's roster, the ability to play right field will be important. Castillo is proving he can do that.
"I don't know that you can make a play better than the one he made -- diving play in foul territory, he gets up, sets his feet, and then he throws a 150-foot strike," said Red Sox manager John Farrell. "A dynamic player, when you consider the skill set that he has. If there was any question on whether he could play right field, he's certainly answering those for us in camp here."
Pitching prospect Brian Johnson allowed six hits and two runs in a four-inning stint. The lefty walked two and struck out three, working at his usual brisk pace.
The Rays were having a "bullpen day" where they used all relievers rather than any of the team's starters. Brad Boxberger wanted to start on Sunday, which is what he did with success as he retired Mookie Betts, Dustin Pedroia and David Ortiz in his one inning of work. Boxberger explained why he wanted to start.
"Having the offseason and the downtime and then kind of having a little bit of a lull in Spring Training where I was throwing later in games because starters were obviously going longer," Boxberger said. "Being able to get back out there and face the middle and top of their lineup is definitely encouraging."
Veteran Grant Balfour, who is hoping to hold down the closing duties for the Rays until Jake McGee returns from an injury, worked a scoreless frame.
Mike Napoli had an RBI double high off the Green Monster for the Red Sox.
Up next: Right-hander Justin Masterson will pitch under the lights in Monday's 7:05 p.m. ET home game against the Twins. Brandon Workman, Robbie Ross Jr., Mujica and Junichi Tazawa could see action out of the bullpen. Right fielder Shane Victorino is expected to play for a third straight day as the Red Sox continue to gauge his durability.
Ian Browne is a reporter for MLB.com. This story was not subject to the approval of Major League Baseball or its clubs.