TORONTO — Presented with an opportunity to end a long road trip on a very high note the Yankees exited Canada with two losses in three games to the rebuilding Blue Jays, and lost ground to the Astros in the race for home-field advantage in the ALCS.

“Losing sucks every time,’’ Aaron Boone said following Sunday’s 6-4 defeat to the Blue Jays in front of 22,562 inside Rogers Centre. “But in a long season, it’s blinders on and let’s go. You have to flush these things, good and bad, every single day and it is something we have done great all year.’’

The loss sent the Yankees into Monday’s day of rest tied with the Astros for home-field advantage. Each team is 98-53 and should the Astros and Yankees finish the season with identical records, Houston would grab the home-field comfort because it won four of seven games against the Yankees.

The Yankees had gone 30-4-8 in their past 42 series. Despite the loss, the Yankees’ magic number to clinch the AL East dropped to three when the Rays lost to the Angels, 6-4, in Anaheim.

After using reliever Chad Green to start a game for the 14th time this year, Jordan Montgomery made his season debut in the second inning. It was the left-hander’s first big-league game since May 1 of last year after undergoing Tommy John surgery.

Dellin Betances also made his 2019 debut and struck out the two batters he faced in the fourth.

Staked to a one run lead by Aaron Judge’s opposite-field homer to right in the first inning, Montgomery gave up three hits and two runs with two outs in the second and the first of Randal Grichuk’s two homers in the third.

“It went good, definitely not great,’’ said Montgomery, who gave up four hits, didn’t issue a walk and struck out two in two innings. “I’m healthy and got my feet wet.’’

While there is an outside chance Montgomery could be a member of the Yankees’ postseason pitching staff, the last two weeks of the regular season will likely serve as peace of mind going into the offseason for the 26-year-old with an 11-7 record in 35 big-league starts before Sunday.

After Grichuk hit a three-run homer off Nestor Cortes Jr. in the fifth with the score tied, 3-3, the Yankees scored just an unearned run in the seventh. In the final four frames, the Yankees left four runners on base and went 0-for-4 with runners in scoring position.

“It’s frustrating anytime you lose a series,’’ said Judge, who was called out on an appealed check swing to end the fifth and called out looking at a ball that appeared low to end the game. “We would get guys on base and we couldn’t get the one big hit to knock them out.’’

Even though the Yankees scored twice in the third inning they had runners on first and second and one out and couldn’t get those runners home.

They also had the bases loaded with two outs and stranded three in the inning. They also stranded two in the seventh when Didi Gregorius struck out and Gleyber Torres grounded to short.

Montgomery and Betances made it back from the IL and Betances has a chance to strengthen a strong bullpen even if he never builds enough arm strength to reach triple digits with his fastball. Luis Severino will make his season debut Tuesday night against the Angels. Adding those three arms to the mix took a little bit of the sting out of dropping two of three to the Blue Jays.

“That’s our trade deadline [moves],’’ Judge said.