Zack Wheeler is taking his talents to South Philly.

In the worst of two worlds for the Mets, the fireballing right-hander won’t only be absent from Queens next season, but he will remain in the division — with a chance to cause further pain for his former club.

Wheeler agreed to terms Wednesday on a five-year contract with the Phillies worth $118 million, an industry source confirmed, putting him in a rotation with Aaron Nola and Jake Arrieta under the leadership of new manager Joe Girardi.

The Mets never made an offer to Wheeler, according to the source. But Wheeler’s camp circled back to the Mets, giving team officials one last chance before accepting the Phillies’ offer. The White Sox, Twins and Rangers were among the other teams interested in Wheeler.

“I’m sad to see Wheeler leave the Mets and to a divisional competitor,” Noah Syndergaard told The Post. “But at the same time I am happy to see him get a fat paycheck. He is an elite pitcher.”

In a starting-pitching market in which Gerrit Cole and Stephen Strasburg are the brightest stars, the 29-year-old Wheeler was considered as maybe the next-best option. Over the past two seasons, he went 23-15 with a 3.55 ERA after recovering from injuries earlier in his career. Among them was a torn ulnar collateral ligament that necessitated Tommy John surgery, costing Wheeler the 2015 and ’16 seasons. Wheeler’s electric arsenal had teams willing to pay nine figures for his services.

The Mets extended a qualifying offer to Wheeler for next season worth $17.8 million, meaning the team will receive a compensatory draft pick next summer.

The Mets acquired Wheeler, then a minor league prospect, from the Giants for Carlos Beltran at the trade deadline in 2011. Beltran was named Mets manager last month, but won’t get an opportunity to reunite with the player for whom he was dealt.

At the Mets’ annual holiday party at Citi Field, just hours before Wheeler’s deal became public, J.D. Davis was asked about the possibility of Wheeler defecting to the Phillies.

“If he goes to Philly, that is a little problematic,” Davis said.

Brandon Nimmo, who played Santa at the event, tried to put a more positive spin on the idea of Wheeler in Philadelphia.

“He’s a great pitcher, but guess what, this whole division is stacked with pitchers,” Nimmo said. “Last year it was Strasburg and [Max] Scherzer, and nobody even mentioned that the Marlins have a great pitching staff and that young core that they have got, so it’s just going to be tough day in and day out, so our offense is going to have to be up for the challenge.”

Only adding to the challenge, the Braves reportedly agreed to a one-year contract worth $18 million with veteran left-hander Cole Hamels.

Wheeler’s departure leaves the Mets with Jacob deGrom, Noah Syndergaard, Steven Matz and Marcus Stroman in the rotation. Stroman was acquired from Toronto at last season’s trade deadline essentially as insurance against Wheeler departing, but the Mets still have a rotation opening.

Previously, general manager Brodie Van Wagenen indicated the Mets could fill the spot by removing Seth Lugo or Robert Gsellman from the bullpen.

But Lugo’s addition to the rotation, especially, would weaken a bullpen that was among the worst in baseball in 2019. As the season concluded, Lugo and Justin Wilson were the only consistent relievers on whom manager Mickey Callaway could depend.

Nimmo was asked where the Mets need to improve.

“Everybody needs bullpen help,” Nimmo said. “The Nationals got through the World Series with basically two relievers, so everyone needs bullpen help and it’s going to take someone stepping up.”