As the wait for Aaron Judge’s uncertain return grows longer, the Yankees decided Thursday night that it was time to upgrade the outfield in his absence, agreeing on a deal to acquire Andrew McCutchen from the Giants for two prospects, a source confirmed.

One of those prospects reportedly is shortstop Abiatal Avelino, who was pulled midway through Triple-A Scranton’s game at Syracuse. Avelino is the Yankees’ No. 23 prospect, according to MLB.com, and was batting .252 with a .663 OPS for the RailRiders. The New York Post was the first to report the McCutchen trade, which is expected to become official Friday.

Judge suffered a fractured wrist on July 26, but Brian Cashman had shown reluctance in making a deal for help, likely because he was hoping for the initial prognosis of a three-week recovery. But now that it’s moved to beyond four weeks, and Judge has yet to pick up a bat, Cashman had to made a move before Friday’s deadline in order for McCutchen to be eligible for the postseason.

The Giants traded for McCutchen, 31, last winter as part of their efforts to revamp a moribund offense -- along with grabbing Evan Longoria from the Rays -- but the makeover didn’t take in the Bay Area. McCutchen, the 2013 NL MVP, was batting .255 with 15 home runs, 55 RBIs and a .772 OPS in 130 games.

As badly as the Yankees needed outfield help, Cashman also had to be mindful of staying below the $197-million luxury tax threshold for this year, and McCutchen allows him to do that. He is making $14.75 million this season, but the Pirates picked up $2.5 million in the swap, so that leaves the Yankees on the hook for roughly $2.04 million for the remainder of this season.

The Yankees started Shane Robinson in right for Thursday’s 8-7 loss to the lowly Tigers, his 17th start in the outfield. In 24 games this season, Robinson was batting .143 (7-for-49) with one homer and a .224 slugging percentage. McCutchen steps into Robinson’s spot on the roster, and with Aaron Boone trying to protect Giancarlo Stanton’s legs for the past month or so, he’ll likely take the biggest chunk of playing time in rightfield.

While the McCutchen deal should greatly help the sagging Yankees get through this injury-marred period, it also says a lot about the Yankees’ concern regarding Judge. It’s possible the team’s puzzling three-week prediction had to do with hiding the Yankees’ desperation in the trade market, but once the initial projection was revealed to being way off, Cashman had to eventually secure a replacement.

Before Thursday’s game, Judge did his usual rehab regimen, which includes running the bases and fielding fly balls in right, with only light tossing. He did, however, play catch from 60 feet, an indication that maybe there was some improvement in the healing process.

Subscribe to Newsday’s sports newsletter

Receive stories, photos and videos about your favorite New York teams plus national sports news and events.

How much is difficult to tell. Judge wasn’t available Thursday to give an update on this progress, and he said earlier this week that he’s still experiencing too much pain to swing a bat. With the minor-league season ending around Labor Day, Judge won’t have a chance to play in the lower levels, and that leaves only the instructional league in Tampa to get him up to speed.

Boone insists that it’s possible for Judge to recover in time to be productive again at the plate, but that’s getting harder to believe as the days go by without significant healing. And without Judge available, the Yankees have been forced to push Stanton to the limit, as he’s played 83 consecutive games and missed only one of their 134 games this season.

Still, Stanton has powered through, and the day after admitting he could use a night off, he drilled career home run No. 300, a laser-shot into the rightfield seats. That was an encouraging sign for the Yankees after Stanton had been through a 10-game homerless drought. And with Gary Sanchez expected back this weekend, the addition of McCutchen might even give Boone the chance to rest Stanton for a day.

The Yankees also have more reinforcements on the way. After Sanchez is activated Saturday, Didi Gregorius (bruised heel) shouldn’t be far behind, with the possibility of him playing again when the Yankees start a nine-game road trip in Oakland on Monday.