BOSTON — The Boston Red Sox are hoping an improbable comeback can jump-start their season.

Rusney Castillo hit a solo homer and an RBI single during a seven-run rally in the eighth inning that sent the Red Sox to a 7-4 win Sunday over the Oakland Athletics for a three-game sweep.

Xander Bogaerts delivered a go-ahead, two-run double. The Red Sox produced eight hits in the rally before ambidextrous Pat Venditte, Oakland’s fifth pitcher of the inning, got the last out.

“I think the way in which we won this one has a chance or an opportunity to have as big an impact as the win itself,” Manager John Farrell said.

Entering the day last in the AL East and five games under .500, the Red Sox provided a glimpse of what type of offense was expected after they spent $183 million on free agents Hanley Ramirez and Pablo Sandoval during the offseason.

“Wow, seven runs in one inning,” Bogaerts said. “A lot of people talk about our offense. This is the kind of offense we can be right there.”

Boston entered with the third-fewest runs in the AL.

Steven Wright (3-2) pitched 3 1/3 innings of shutout relief for the win. Tommy Layne threw a perfect ninth for his first save.

Kendall Graveman took a shutout into the eighth inning before Castillo led off with a homer. Consecutive singles by Dustin Pedroia, Brock Holt and Hanley Ramirez made it 4-2, David Ortiz hit a sacrifice fly, and Bogaerts doubled off Tyler Clippard (0-3) to give the Red Sox a 5-4 lead.

Alejandro De Aza and Castillo each added an RBI single.

“Any loss is tough especially when you have a four-run lead heading into the eighth, it doesn’t make it any easier,” Clippard said.

The Athletics finished a six-game road trip 3-3 after sweeping the Tigers. It would have been their first winning trip since last June.

“We played great in Detroit,” Manager Bob Melvin said. “We come in here and lose a couple of tough ones where we’re in it up until the last at-bat, and then today it looked like certainly early on and deeper into the game we felt like we had a nice win to go home on a 4-2 road trip, but not much you can do about it now.”

Graveman blanked Boston on five hits and took a 4-0 lead into the eighth. He was pulled after Castillo’s homer.

Mark Canha and Josh Reddick each had three hits for Oakland.

Clay Buchholz allowed four runs and 10 hits – five doubles – in 4 2/3 innings.

“That’s how good everybody thinks this team is,” he said. “It took a while for it to happen.”

The Athletics scored three times in the second. Canha had an RBI double, Reddick scored on a wild pitch and Eric Sogard hit a run-scoring single.

The A’s made it 4-0 in the fourth on Josh Phegley’s RBI double before leaving the bases loaded.

NOTES: It was Boston’s first series sweep of the season and first three-game winning streak since early April. … Dustin Pedroia went 2 for 5 and is hitting .394 over 16 games since being moved into the leadoff spot. …

Farrell announced before the game that Wright is moving from the rotation to the bullpen, as the Red Sox switch back to a five-man rotation.

Red Sox right-hander Justin Masterson, on the 15-day disabled list because of shoulder tendinitis, is scheduled to make his third rehab start Wednesday, for Triple-A Pawtucket.