BOSTON — J.D. Martinez hit his 41st home run and the Boston Red Sox moved closer to clinching the AL East title, completing a three-game sweep of the Toronto Blue Jays with a 4-3 victory Thursday night.

Xander Bogaerts scored the go-ahead run on an eighth-inning error after the Blue Jays rallied in the top half with two runs to tie it 3-all.

Rafael Devers also homered for the major league-leading Red Sox (101-46), who pulled 101/2 games ahead of the idle New York Yankees and decreased their magic number to six for clinching a third straight division crown.

Boston is the only team in the majors that’s already locked up a playoff berth.

Brandon Workman (5-0) faced one batter, ending Toronto’s eighth-inning rally, and got the win. Craig Kimbrel earned his 40th save.

Danny Barnes (3-3) took the loss.

Lourdes Gurriel Jr. homered for the Blue Jays.

Gurriel’s drive pulled Toronto to within 3-2 in the eighth and the Blue Jays added another run after Justin Smoak walked with two outs and Kendrys Morales followed with a single. Joe Kelly hit Randal Grichuk with a pitch to load the bases, then plunked Kevin Pillar to force in the tying run.

Bogaerts stole third after hitting a one-out double in the eighth and scored when second baseman Yangveris Solarte dropped a pop-up in shallow right field.

Devers hit a solo homer to right with two outs in the sixth off Mark Leiter Jr., putting Boston up 3-1.

Martinez went deep in the second, tying Oakland’s Khris Davis for the major league lead in homers.

Smoak singled home Gurriel in the third, and Ian Kinsler had a sacrifice fly for Boston in the bottom half.

Sam Gaviglio pitched 31/3 innings for Toronto, allowing two earned runs and six hits with one walk and one strikeout.

Eduardo Rodriguez struck out seven over six innings for the Red Sox. Rodriguez retired his last nine batters, striking out two in the sixth before Boston turned it over to the bullpen in the seventh. He allowed one run on five hits and didn’t walk a batter.

NOTES: Third baseman Eduardo Nunez left in the fourth with soreness in his right knee after hitting a leadoff double. Nunez, who also tripped and stumbled over first base while running out a fielder’s choice in the second, was replaced by Devers.

HOURS AFTER President Donald Trump disputed the death toll suffered by Puerto Rico from Hurricane Maria last year, Red Sox Manager Alex Cora called his comments “disrespectful.”

“To be tweeting about 3,000 people and being efficient, it’s actually disrespectful for my country,” Cora said. “We see it that way. I know he probably doesn’t feel that way.”

Trump tweeted twice Thursday morning about the death toll, claiming that the number of deaths had been exaggerated. Cora, a native of Caguas, Puerto Rico, said that he was frustrated that the argument over the number of deaths had become political.

“Three-thousand, six, 18, I don’t know,” Cora said. “We will never know how many we lost. I hate that people make it a political issue. This is about human beings. The people that went through this, they know what happened.

Cora said that there was no question the U.S. government had helped Puerto Rico in the wake of the storm and thanked the government for its help.