Yankees starting pitcher Frankie Montas throws during the first inning...

Yankees starting pitcher Frankie Montas throws during the first inning of a game against the Brewers on Friday in Milwaukee. Credit: AP/Morry Gash

MILWAUKEE — Frankie Montas was acquired at the trade deadline in large part because of his impressive career numbers against the Astros, the Yankees’ No. 1 postseason nemesis in recent years. But the righthander isn’t doing much when it comes to aiding their cause to get there.

Spotted a five-run lead through the Yankees’ first two turns at the plate Friday night, Montas failed to make it through four innings against the Brewers.

And while Montas was long gone by the time the Yankees lost, 7-6, on Garrett Mitchell’s walk-off single with the bases loaded and two outs in the bottom of the ninth, he certainly helped paved the way to the defeat.

After Josh Donaldson homered off the leftfield foul pole to tie the score at 6 in the top of the ninth, Hunter Renfroe opened the bottom of the inning with a double against Clay Holmes and moved to third on Kolten Wong’s groundout to short. With former Yankee Andrew McCutchen up, the Yankees moved Miguel Andujar from leftfield to first base, giving themselves a five-man infield. After McCutchen walked and Jace Peterson struck out, Andujar went back to leftfield and Victor Caratini walked to load the bases for Mitchell, who lined a 1-and-2 pitch past Holmes into centerfield for the game-winner.

After rallying from the early 5-0 deficit, the Brewers went ahead in the eighth on a two-out error by Isiah Kiner-Falefa on Willy Adames’ grounder in the hole with runners at second and third (the play easily could have been scored an infield single). It came against Jonathan Loaisiga, the Yankees’ seventh of eight pitchers. It was preceded by what the Yankees thought was an inning-ending double-play ball off the bat of Christian Yelich, but after a Brewers challenge, he was ruled safe.

“I just missed it,’’ Kiner-Falefa said. “I went for the backhand. I knew Adames is a good runner, I was ready to get rid of it and I just missed it. It was my fault.

“I take the blame for this loss tonight . . . No plays are easy here, but that’s one that cost us the game tonight. I make that play, JD, that homer puts us up and we’re not in that situation at the end. I have to make that play to win that game. That’s one I wish I had back. It cost us the game tonight.”

One pitch after Donaldson hit his 14th homer, Oswaldo Cabrera doubled to right-center before moving to third on Kiner-Falefa’s sacrifice bunt. Miguel Andujar struck out looking on a pitch that appeared to be well out of the strike zone — leading to Aaron Boone’s ejection after the inning — and Kyle Higashioka flied out.

“We had pitches within that at-bat to do what we needed to do,’’ Boone said. “It’s frustrating when there’s a non-competitive pitch that gets called, but that’s part of it and we still have to find a way. They made a few more plays than us in the end.”

The Yankees (87-57), who had won eight of their previous 10 games, saw their AL East lead over the Blue Jays trimmed to 5 1⁄2 games. Aaron Judge had two hits and a walk but stayed put at 57 homers.

Montas, 1-3 with a 6.35 ERA in eight starts as a Yankee, allowed four runs, four hits and four walks in 3 1⁄3 innings.

“I haven’t really performed how I wanted to perform,’’ he said. “I’m not really worried about it. I know what I can do. I know what I’m capable of doing.”

What gives him the confidence that he can turn it around? “It’s not my first year,’’ he said. “I know what I’m capable of when I’m rolling.”

The Yankees took another loss, though it was too early to determine how severe. Jose Trevino, who took a foul ball off his right knee in the fifth inning and suffered a contusion, was replaced by pinch hitter Higashioka in the seventh (first baseman Marwin Gonzalez also left the game because of illness and was replaced by Cabrera, who had never before played first base).

The Yankees scored three runs in the first. After Judge reached on an infield single and Gleyber Torres doubled to right-center to put runners on second and third with one out, Donaldson lifted a sacrifice fly to the warning track in left-center. Kiner-Falefa and Gonzalez followed with RBI singles.

In the second, Donaldson beat out a potential inning-ending double-play ball to allow a run to score, and when Wong’s errant throw to first got away from Rowdy Tellez, the Yankees had a 5-0 lead.

Adames hit a three-run homer off Montas in the bottom of the inning. The Brewers tied it in the fourth on an RBI ground-rule double by Adames and a sacrifice fly by Tellez.

More Yankees headlines