Labor Secretary Alex Acosta said Friday he would resign in a surprise appearance with President Donald Trump.

“I thought the right thing was to step aside,” Acosta told reporters at the White House. “It would be selfish for me to stay for me to stay in this position.”

Acosta leaves after heightened scrutiny of his handling of sexual misconduct charges against Jeffrey Epstein following the announcement of the financier’s indictment on Monday. As the top federal prosecutor in Florida in 2007 and 2008, Acosta signed off on a lenient plea deal with Epstein that allowed him to resolve the earlier charges by serving 13 months in a county jail and registering as a sex offender.

Acosta said Wednesday in a news conference that Epstein would have escaped jail time altogether had his office not been involved in the case. But he was criticized by some Democrats for not offering an apology to Epstein’s victims, who didn’t know about the plea deal while it was being negotiated.

“In so many ways I hate what he’s saying now because we’re going to miss him,” Trump said. He said he had told Acosta he didn’t have to resign.