NEW YORK — Sensing the season’s dwindling days, the New York Yankees opened their penultimate homestand by falling behind on Masahiro Tanaka’s seventh pitch of a sunny Labor Day afternoon.

Jacoby Ellsbury turned the deficit into a lead on R.A. Dickey’s third offering of the day, and New York remained on the periphery of contention for a postseason berth with four weeks remaining.

Ellsbury drove a 73 mph knuckleball over the right-field short porch for a two-run homer, then added an RBI single to lead the Yankees over the Toronto Blue Jays 5-3 Monday and keep New York 3 1/2 games back in the AL wild-card race.

“It’s almost imperative,” said Brett Gardner, who singled one pitch ahead of Ellsbury’s seventh homer. “At this point, we have to win every series the rest of the way. We’ve got to play well, and two-out-of-three is the worst-case scenario for us.”

Starting a 10-game homestand that includes four games against Tampa Bay and three vs. the Los Angeles Dodgers, New York (71-65) matched its season high of six games over .500.

AL East-leading Toronto (77-60), which remained one game ahead of Boston, had been 9-3 against the Yankees this year and won seven of the prior eight matchups. The Blue Jays jumped in front when Devon Travis doubled and Jose Bautista singled, both on 0-2 counts.

“I felt like I was all over the place,” Tanaka said through a translator.

Tanaka (12-4) gave up three hits in the first but only one run, helped when Bautista got thrown out at the plate on a grounder, and settled down to win his fifth straight decision.

Gardner took a strike in the bottom half and singled to center, and Ellsbury drove a high knuckler 351 feet. Ellsbury had three hits, including two against Dickey that lifted his average against the knuckleballer to .306 (11 for 36).

“You just try to anticipate it falling back in the zone,” Ellsbury said. “Last time he threw me a fastball, I hit a triple.”

Ellsbury added an RBI single in the third, and rookie Travis Austin hit his second double of the game in the fourth, a drive off the wall in left-center that drove in two runs for a 5-1 lead.

Tanaka allowed two runs and seven hits in 6 1/3 innings, leaving after a leadoff walk and a fly ball by Dioner Navarro that 6-foot-7 Aaron Judge caught against the top of the right-field wall.

Jonathan Holder, who made his big league debut Friday, got an out but walked his next two batters. Edwin Encarnacion hit a two-run, opposite-field single to right off Ben Heller for his third hit, and Tommy Layne — New York’s third straight rookie reliever — retired pitch hitter Russell Martin on a looping ball to second baseman Starlin Castro.

Dellin Betances, the Yankees’ sixth pitcher, got three straight outs for his ninth save.

Dickey (9-14) allowed five runs and seven hits in four innings on a blustery afternoon, his second shortest start this season. He is 0-6 in his last nine starts at Yankee Stadium.

“I had a lot of movement on it,” he said of his knuckler. “Sometimes this game’s a matter of centimeters, you know, one that gets off the barrel, doesn’t get off the barrel and it’s popped out to right field.”

MOVING IN

Eric Young Jr. took over Alex Rodriguez’s locker stall and Greg Bird moved into Carlos Beltran’s. Bird, sidelined all season following surgery in February to repair a right labrum tear, hit in a batting cage for the first time since the operation. He expects to face pitching in the instructional league for two weeks starting Sept. 26 and play in the Arizona Fall League.

POWER OUTAGE

New York had 15 hits, all singles, in the weekend series at Baltimore, the first big league team to go without an extra-base hit in a series of three games or longer since the Chicago White Sox at Minnesota from Sept. 14-16, 2004. The Yankees had not done that since July 26-28, 1974, also at Baltimore.

SLIDING

Judge was 0 for 3 with three strikeouts, dropping his batting average to .169, and has 35 strikeouts in 65 at-bats. … Didi Gregorius is in a 1-for-19 slump.

TOP SPY

John O. Brennan, the director of the Central Intelligence Agency, threw out a ceremonial first pitch.

TRAINER’S ROOM

Yankees: With RHP Chad Green sidelined with an elbow injury, manager Joe Girardi said his starting pitcher Wednesday could be Bryan Mitchell, who broke a toe in spring training and has a 4.29 ERA in six minor league rehabilitation starts. Girardi said his other option was “Johnny Wholestaff” — a reference to using a combination of relievers. Green is expected to have a contrast agent MRI on Tuesday. … OF Aaron Hicks was placed on the 15-day DL with a right hamstring strain, a move retroactive to Thursday.

UP NEXT

RHP Luis Cessa (4-0) is to start for the Yankees on Tuesday and RHP Aaron Sanchez (13-2) goes for the Blue Jays.