MILWAUKEE — Appropriately enough, the winning run scored in a cloud of confusion.

With the bases loaded in the 11th inning, Brewers shortstop Jonathan Villar let Matt Reynolds’ soft liner hit his glove and trickle away. He retrieved the ball and tossed to second for the force. Nevertheless, second baseman Scooter Gennett pursued Kelly Johnson as he retreated back to first base, even though he was already forced out.

By the time the dust had settled, Asdrubal Cabrera scored from third base, giving the Mets the winning run in a sloppy 2-1 victory against the Brewers on Friday night.

Matt Harvey pitched brilliantly and Yoenis Cespedes hit his 16th homer of the season. But those feats were obscured by futility.

The Mets stranded 11 runners and left the bases loaded in the ninth, and the Brewers proved equally as deficient.

Harvey only added to the growing body of evidence that he has emerged from his crisis of confidence. The Brewers managed only one run and two hits in six innings against Harvey, who flashed command of his fastball and sharpness on his secondary pitches.

He walked two but struck out eight, another encouraging sign that he has regained his form. In 20 innings over his last three starts, he has allowed only two runs.

But despite his 0.90 ERA during that span, Harvey has only one win to show for it. That’s because the Mets have given him only two runs of support.

The Brewers had a run taken away in the third when a video review showed that Aaron Hill was thrown out at home. He was trying to score from second on Villar’s comebacker that struck Harvey on the leg and gotten away from shortstop Cabrera.

Initially, umpires ruled Hill safe, though the call was overturned after a review lasting more than three minutes. The delay lingered even more when Brewers manager Craig Counsell asked the umpires to review the play again, this time to determine whether catcher Kevin Plawecki had illegally blocked the plate. He did not.

But the Brewers pushed ahead anyway, taking a 1-0 lead in the fifth on Ramon Flores’ sacrifice fly to score Kirk Nieuwenhuis, who tripled to the rightfield corner.

The Mets tied it in the sixth, and it required just one timely swing from Cespedes, who has come roaring out of his slump. Cespedes, who had five singles in his previous two games, hammered a shot that sailed over the bullpen in left-center. It was the slugger’s first homer since May 23, a stretch of 52 at-bats.

For an instant, the Mets appeared to have taken the lead in the seventh, when Kelly Johnson’s drive to straightaway centerfield seemed destined to clear the fence. But Nieuwenhuis burned his former team for a second time, perfectly timing his leap at the centerfield fence to rob a go-ahead homer.

It was an eventful first game back for Johnson, who was traded from the Braves on Wednesday and took Ty Kelly’s spot on the roster when he was activated yesterday.

Starting at second base, Johnson singled, doubled and nearly homered had it not been for Nieuwenhuis’ catch. Johnson also made a baserunning gaffe, getting tagged out at second on a grounder up the middle.

Notes & quotes: Travis d’Arnaud (right rotator cuff strain) will catch for the first time during his rehab assignment today. Thus far, he has been limited to designated hitter duty . . . Walker was out of the starting lineup one day after he was struck in the chest by a hard one-hopper.