Embattled Labor Secretary Alexander Acosta resigned Friday morning amid the fallout over his handling of a sex trafficking case involving billionaire financier Jeffrey Epstein.

“I called the president this morning and told him that I thought the right thing was to step aside,” Acosta said in a joint appearance with President Trump at the White House.

He said he didn’t want the Epstein case to distract from the Trump administration’s accomplishments, including the strong economy.

The president — who named Acosta’s deputy, Patrick Pizzella, as acting secretary — said Acosta called him earlier in the day to inform him of his decision.

Trump told reporters before departing for Milwaukee, Wisconsin, that Acosta was a “great labor secretary, not a good one,” adding that Acosta did a “very good job.”

“He was a great student at Harvard. He’s Hispanic, which I so admire, because maybe it was a little tougher for him and maybe not,” Trump said of Acosta, the son of Cuban refugees and the first Hispanic member of his cabinet.

The president said in a tweet later that Acosta told him that he “felt the constant drumbeat of press about a prosecution which took place under his watch more than 12 years ago was bad for the Administration,” so he “graciously tendered his resignation.”

Democrats welcomed the news of Acosta’s departure.

Massachusetts Democratic Rep. Ayanna Pressley responded “good” when she heard of his resignation Friday morning.

“It’s about time,” said Rep. Debbie Wasserman Schultz (D-Fla.). “I have said repeatedly that a person like Acosta who could violate the rights of young women who were sexually abused repeatedly and then be elevated to the most important role in the nation that protects the vulnerable against human trafficking … that’s not a person who deserves being vested with that responsibility.

“He should have never been trusted with it and he was trusted with it by the president for too long. It’s the right thing to do that he has decided to resign,” she said.

Democratic Rep. Raja Krishnamoorthi of Illinois called the treatment of women in the Epstein case reprehensible.

“I hope this is a lesson for everybody that this type of behavior is unacceptable,” Krishnamoorthi said of Acosta’s resignation.

Acosta, 50, who has served in Trump’s cabinet since April 2017, was the US attorney for the Southern District of Florida from 2005 through 2009.

In 2008, he was involved in a sweetheart plea deal that allowed Epstein to avoid prosecution on federal charges of molesting teenage girls.

The billionaire hedge fund manager — whose social circle over the years has included Trump, former President Bill Clinton and Britain’s Prince Andrew — pleaded guilty to state charges, spent 13 months behind bars and registered as a sex offender.

Acosta’s role in the Epstein case came under renewed scrutiny after federal prosecutors in New York filed similar sex trafficking charges this week against Epstein, who pleaded not guilty.

The federal prosecutors in the Big Apple said they were not bound by the widely criticized plea deal, which a federal judge in West Palm Beach, Florida, ruled in February had violated the victims’ rights.

The Epstein case came up during Acosta’s Senate confirmation hearing, but the GOP-majority Senate approved him 60-38.

The president said earlier this week that he felt “very badly” for Acosta.

“I met Secretary Acosta the first time I know when I made the deal to bring him into the administration. I can tell you that for two and a half years he’s been just an excellent secretary of labor,” Trump said Tuesday.

“He’s done a fantastic job,” the president adding, crediting Acosta with helping boost the economy.

On Tuesday, Trump also distanced himself from Epstein, saying he was “not a fan” and that the former pals had a “falling out” years ago.

Democratic House Speaker Nancy Pelosi and Democratic Senate Minority Leader Chuck Schumer had called on Tuesday for Acosta to step down.

Acosta responded to the criticism by saying on Twitter that Epstein’s crimes were “horrific” and that the secretary was happy prosecutors were moving forward based on new evidence and testimony that could “more fully bring him to justice.”

On Wednesday, he held a news conference to defend his handling of the deal and said Epstein would have had an even lighter sentence if not for the deal.

He said a state attorney had been preparing to allow Epstein to plead guilty to a single charge of solicitation that did not make a reference to the age of the female minor.

Under that deal, Epstein would not have faced jail time and would not have been required to register as a sex offender, Acosta noted.

“We wanted to see Epstein go to jail,” he said. “He needed to go to jail.”

Acosta would not say if he would make the same decision about Epstein now — during the #MeToo era, which has led to the downfall of several powerful men publicly accused by woman of sex crimes.

He suggested that the evidence prosecutors now have — including lewd photographs of underage girls — were not available to his team when he was Miami’s US attorney.

Marissa Schultz contributed reporting.