BOSTON — The Blue Jays almost balked away a pivotal game in their post-season chase.

With Toronto leading in the eighth inning thanks to another strong start from 20-game winner J.A. Happ, Roberto Osuna balked in the tying run. But Ezequiel Carrera delivered a sacrifice fly in the ninth, and Toronto beat Boston 4-3 on Saturday night to move into a tie with Baltimore for the top spot in the AL wild-card race.

"We had the lead and the tying run scores on balk. I was worried about the baseball gods," said manager John Gibbons, whose team is tied with the Orioles at 88 wins with one game to play. "We want to enjoy this one. They're hard to come by."

Toronto owns the tie-breaker with Baltimore and would host the wild-card game if it wins the season finale Sunday. Detroit is also still in the wild-card hunt but would require losses by the Jays or Orioles to get in.

With the loss, Boston fell one-half game behind Cleveland in the race for home-field advantage when their AL Division Series begins on Thursday.

"Obviously, we would like the home-field advantage," Boston utilityman Brock Holt said. "We'll come ready to go tomorrow. Hopefully we'll play that first game here."

One night after the Blue Jays blew a 3-1 lead and gave up the winning homer to the soon-to-be-retired David Ortiz, Happ seemed poised to pick up his 21st win. But with Toronto leading 3-2 in the eighth, Mookie Betts doubled, took third on Holt's hard-hit double-play ball and then scored to tie it when the Blue Jays closer Osuna stopped his motion after starting to get into the stretch.

"That was a pretty obvious one," said Betts, who had two hits and scored twice for Boston.

Osuna got Jackie Bradley Jr. to end the inning.

With Red Sox closer Craig Kimbrel (2-6) pitching in the ninth, Michael Saunders drew a leadoff walk, and then pinch-runner Dalton Pompey took second on a sacrifice bunt, third on a wild pitch and scored on Carrera's fly to left.

"We grinded out at-bats," said Toronto's Kevin Pillar, who drove in three runs on a pair of RBI singles. "We know what the alternative is: going home. You don't put this much work in to fold up shop and go home."

Kimbrel has losses in two of his last three appearances, issuing six walks while completing two innings. Since Sept. 22, his ERA has risen from 2.52 to 3.40.

The 21-year-old Osuna (4-3) retired the Red Sox in order in the ninth to recover from his sixth blown save of the season.

FOR STARTERS

Happ pitched 6 1/3 innings of four-hit ball, allowing allowed two runs while walking five and striking out one.

Boston starter Eduardo Rodriguez allowed three runs — all on RBI singles by Pillar — three hits and five walks, striking out nine.

FAREWELL PAPI

Ortiz walked and singled in three plate appearances before he was replaced in the fifth inning by a pinch-runner. The Red Sox designated hitter tipped his batting helmet to the crowd that stood and chanted "Papi!" for the second consecutive night.

Ortiz, 40, has announced this season will be his last. The Red Sox already extended his career by winning the AL East, but they are using his final regular season series to celebrate him.

Before Saturday's game, Ortiz was joined on the field by other Boston sports stars, including Bruins legend Bobby Orr, NFL Hall of Famer Andre Tippett and the entire current Celtics' roster. Several of the players asked Ortiz to sign their jerseys and pose for selfies with them.

UP NEXT

Blue Jays: RHP Aaron Sanchez (14-2, 3.06 ERA) goes in the regular season finale Sunday. He's allowed one run over six innings in each of his last two starts after extended rest for a blister.

Red Sox: Former Blue Jays left-hander David Price (17-9, 4.04) will start for Boston on Sunday. He took the loss in his previous start Tuesday against the Yankees, giving up six runs and 12 hits in 6 1/3 innings, halting his career-best, eight-game winning streak.