The specter of a $100 million libel suit scared CNN into retracting a poorly reported story that slimed an ally of President Trump’s — and forcing out the staffers responsible for it, The Post has learned.

The cable network’s coverage of Trump transition team member Anthony Scaramucci came amid federal scrutiny of corporate parent Time Warner’s pending purchase by AT&T — and the widespread belief among media execs that CNN President Jeff Zucker can’t survive a merger.

CNN immediately caved after Scaramucci, a financier and frequent network guest, cried foul and threatened to take legal action, sources said Tuesday.

Scaramucci got an unusual public apology but still hired a top Manhattan lawyer to put further pressure on CNN and “look after [his] interests in this matter,” one source said.

Sources also said the three journalists responsible for the retracted story — reporter Tom Frank, editor Eric Lichtblau and Lex Haris, who headed the CNN Investigates unit — were urged to resign.

“They called them in and said they’d pay out their contracts, but they should leave immediately,” one source said.

Zucker was afraid of facing a high-profile suit from Scaramucci while the US Justice Department weighs the proposed $85.4 billion media merger.

Meanwhile, a CNN insider said staffers are furious at “having lost the moral high ground because of this story.” Sources said Zucker tried to rally his staff during a Tuesday morning conference call.

“Zucker stressed that this issue was a ‘lapse in editorial standards’ and said it was a lesson to all reporters and editors to continue to strive for strong, accurate reporting,” a source said.

At last week’s Cannes Lions festival in France — where Zucker boasted that viewers trust CNN “more than ever” — rumors were rife that he’d be out of a job if the AT&T deal goes through.

“It’s not just Jeff Zucker, all Time Warner executives are anxious about if they will survive the merger,” a media source said Tuesday.

“What is interesting is that the AT&T execs who will decide who goes and who stays are [AT&T CEO] Randall Stephenson and [AT&T Entertainment Group CEO] John Stankey — who have a very good relationship with the current administration.”

Trump — a fierce critic of CNN — publicly opposed the merger during the campaign. Sources said Scaramucci, a frequent guest on CNN to defend the president, was treated like a star at Saturday’s wedding of Treasury Secretary Steven Mnuchin and Louise Linton in Washington, DC.

“Everyone at the White House has been high-fiving each other over Anthony’s success in embarrassing CNN,” one attendee said.

“Trump is thoroughly enjoying this, and Anthony got endless slaps on the back at Steve’s wedding.”

The retracted story was based on a single, anonymous source who claimed the Senate Intelligence Committee was probing ties between the Trump administration and a Russian government-owned investment fund.

The story, posted on CNN.com on Thursday, also claimed the Treasury Department was believed to be investigating Scaramucci over a purported Jan. 16 meeting with the fund’s director general.

In an Editor’s Note posted late Friday , CNN said the story had been deleted for not meeting “editorial standards,” with the network later revealing a “breakdown” in pre-publication vetting that typically involves “fact-checkers, journalism standards experts and lawyers.”

White House spokeswoman Sarah Huckabee Sanders said Tuesday she wasn’t sure if CNN’s handling of the matter was “good enough” for her boss, who went on a Twitter tirade against the news channel earlier in the day.

“I think that we have gone to a place where if the media can’t be trusted to report the news, then that’s a dangerous place for America, and I think if that is the place that certain outlets are going, particularly for the purpose of spiking ratings, and if that’s coming directly from the top, I think that’s even more scary,” she said.

“I think that we should take a really good look at what we are focused on, what we are covering, and making sure that it’s actually accurate and it’s honest,” she added.

CNN’s retraction of the Scaramucci story was the latest in a string of recent embarrassments, including the firing earlier this month of “Believer” series host Reza Aslan after he called Trump a “piece of s–t” on Twitter.

The network also fired comedian Kathy Griffin — longtime co-host of its New Year’s Eve coverage — over a photo that showed her posing with a prop resembling Trump’s bloody, severed head, and had to own up to a story that incorrectly predicted what fired FBI Director James Comey would testify about before Congress.

CNN did not immediately respond to a request for comment.

Following Friday’s apology, Scaramucci tweeted that “CNN did the right thing. Classy move. Apology accepted. Everyone makes mistakes. Moving on.”

On Tuesday, he retweeted a message from CNN “Reliable Sources” host Brian Stelter saying that “nothing in my story should be taken to imply that Scaramucci is under investigation,” as well as a meme portraying Trump as Batman driving the Batmobile.

The image also shows Vice President Mike Pence as Robin, holding the “Bat Phone” and saying: “SORRY HE CAN’T TALK RIGHT NOW — HE’S BUSY WINNING!!!!”

Additional reporting by Bob Fredericks and Bruce Golding