TORONTO — A tough weekend for Clay Buchholz ended with a win and an appreciative handshake from Manager John Farrell.

Dustin Pedroia hit an RBI double in the 11th inning, and the Boston Red Sox beat the Toronto Blue Jays 5-3 on Sunday to avoid a three-game sweep.

Boston recorded its 13th comeback victory one day after losing 10-9 on an infield single in the ninth. The Red Sox lost 7-5 Friday.

“On the heels of two really tough days up here I thought we battled back, took the lead, gave it up and kept coming,” Farrell said. “I couldn’t be more proud with the energy and effort.”

Blake Swihart drew a one-out walk against Gavin Floyd (2-4) and moved to third when Floyd threw a wild ball four to the next batter, Mookie Betts.

Drew Storen came on to face Pedroia, who hit a ground-rule double to right-center. Pedroia went 2 for 6 with two RBI.

Xander Bogaerts followed with an RBI groundout. He went 1 for 6, extending his hitting streak to 22 games.

Removed from Boston’s rotation Friday after losing his previous two starts, Buchholz (3-5) worked one inning for the win in his first relief appearance since Aug. 17, 2008.

“He handled it very well,” Farrell said. “He had a good cutter, a good fastball.”

As Buchholz dressed in the clubhouse afterward, Farrell stopped by his locker for a congratulatory handshake.

“He understands how I’ve felt about the whole situation,” Buchholz said. “I don’t think anybody would be human as a baseball player if they didn’t take it as a slap in the face or as ‘You’ve got to get better.’ That’s sort of how I took it and he understood that.”

Eduardo Rodriguez will replace Buchholz in Boston’s rotation beginning with Tuesday’s game at Baltimore.

Koji Uehara finished for his first save as Boston became the first AL team to reach 30 wins.

Blue Jays Manager John Gibbons said Floyd is “worn down” after pitching three times in four days and suggested Toronto would make a move to reinforce its bullpen Monday.

Jose Bautista hit a two-run homer for Toronto, which had won a season-high four straight.

It was the 14th loss of the season for the Blue Jays’ bullpen, matching Atlanta and Cincinnati for most in the majors.

Toronto trailed 3-2 before Edwin Encarnacion tied it with a leadoff homer against Heath Hembree in the eighth, his 11th.

Making his first start in Toronto since helping the Blue Jays reach the American League championship series last October, David Price gave up two runs and five hits in 61/3 innings, leaving to a loud ovation from the crowd of 47,916.

Bautista opened the scoring with a drive off the left-field foul screen in the fifth, his 11th. It was Bautista’s sixth career homer off Price, the most by any opposing batter.

NOTES: Red Sox designated hitter David Ortiz was scratched with a sore left foot. He was hit on the foot by a pitch in the fifth inning of Saturday’s 10-9 loss and struck out on the play. X-rays were negative and Ortiz is day to day.