BOSTON — Rick Porcello struggled in his final playoff tuneup. No matter, he had another AL Cy Young winner to bail him out.

Porcello gave up three runs in the first inning and five in all, but David Price came out of the bullpen with four straight outs to help the Boston Red Sox beat Toronto 10-7 on Wednesday night and lower their magic number to two.

“I think he’ll be a weapon out there,” said Blue Jays Manager John Gibbons, who had Price on his team for the 2015 pennant race and playoffs. “It was good to see him back out there. I think he’s going to be huge for them in the playoffs.”

The Red Sox maintained a three-game lead in the division over the second-place Yankees, who beat Tampa Bay 6-1 on Wednesday night. Boston, which is already guaranteed at least a wild-card berth, could clinch the first back-to-back AL East titles in franchise history with a victory over Houston on Thursday and a New York loss to the Rays.

“The clock’s running out. We’ve got to win ballgames,” Porcello said. “Talk about the playoffs and stuff, but we haven’t clinched the division yet. We have to do that to put ourselves in a position where we don’t have to play a wild-card game. These games are important.”

Hanley Ramirez and Xander Bogaerts homered in a five-run third inning for Boston after Porcello (11-17) gave up the three runs in the first. The Red Sox scored one in the first and three in the second and then took a 9-4 lead in the third to chase Marco Estrada (10-9) and snap a two-game losing streak.

Porcello allowed five runs, seven hits and two walks, striking out eight in 52/3 innings. A year after winning a career-high 22 games to earn AL Cy Young honors, the 28-year-old right-hander posted the most losses in his career. With a chance to become baseball’s first 20-game loser since 2003, Porcello went 2-0 with a no-decision in his last three starts.

“After a rough start to the ballgame, he settled down just enough,” Red Sox Manager John Farrell said. “And the offense covered it.”

Price pitched 11/3 perfect innings, striking out three, as he works his way back from left elbow problems that kept him on the disabled list for most of the year. It was his third relief appearance since returning on Sept. 14; he is 1-0 with a 0.00 ERA, striking out nine in six innings.

“The three appearances he’s made for us out of the bullpen, they’ve been extremely consistent and powerful,” Farrell said. “Hopefully he’s getting adapted a little bit more to the role.”

Mitch Moreland homered for the Red Sox. Bogaerts had three hits and drove in four runs, including a three-run homer in the third to make it 9-4.

Estrada allowed eight runs – seven earned – nine hits and a walk, striking out two while recording just seven outs and losing for the first time in six decisions. He had only allowed two earned runs in his previous three starts against Boston this season.

Jose Bautista, Darwin Barney and Teoscar Hernandez homered for the Blue Jays, who hit 10 home runs in the three-game series. Hernandez has eight since he was called up on Sept. 1 – a franchise record for rookies in the month.

“We hung in there. We scored some runs,” Gibbons said. “We just couldn’t stop them.”

Bogaerts scored two runs, the first when he came around from first on Dustin Pedroia’s single in the second inning and slid in under the tag headfirst. Home plate umpire Larry Vanover ruled him out, but Bogaerts came up signaling emphatically for Farrell to challenge; replays showed Bogaerts got his hand on the plate before catcher Russell Martin caught his thigh with the tag.

“They’re all competitors,” Farrell said. “They all think they’re safe.”

NOTES: RF Mookie Betts (sore left wrist) and INF Eduardo Nunez (right knee injury) were out for the second straight game. Farrell said before the game that Betts was “improved” and they hoped to have him available if needed to pinch hit after further treatment. . Nunez did some running and said he was trying “everything to get back on the field.”