The US president was asked in 2015 about Epstein and the alleged sexual abuse that took place on Little St James, the Caribbean island owned by the disgraced late financier who died in a prison cell in August last year.
"That island was really a cesspool, there's no question about it, just ask Prince Andrew - he'll tell you about it,” Mr Trump told journalists at an event hosted by Bloomberg, shortly before he entered the presidential race. "The island was an absolute cesspool."
According to flight logs, the Duke of York paid at least one visit aboard Epstein's private jet to the island, although former staff claimed he visited Little St James several times.
Appearing to deny all knowledge of the case on Tuesday, however, Mr Trump claimed in a press briefing: "I don't know the situation with Prince Andrew. Just don't know, not aware of it,” he said as he wished Ghislaine Maxwell, Epstein’s longtime associate and former girlfriend, well.
The president was asked whether he thought Ms Maxwell, who was arrested earlier this month on sex-trafficking charges, was "going to turn in powerful men".
"I don't know, I haven't really been following it too much. I just wish her well, frankly,” he replied, in an extraordinary intervention.
Mr Trump and his wife Melania were photographed with Epstein and Ms Maxwell at the president's Mar-a-Lago hotel in Florida in 2000.
Virginia Roberts Giuffre has claimed she was recruited by Ms Maxwell, trafficked from the US to London, and forced to sleep with Prince Andrew when she was 17.
The Duke has always strongly denied the claims and said he has no recollection of meeting Ms Giuffre. Prosecutors in New York are appealing to the Duke of York to talk to the FBI about his alleged association with Epstein and Ms Maxwell.
There has been speculation that Ms Maxwell could give information to authorities about the Duke and other powerful men she has met including Bill Clinton and Mr Trump, neither of whom have been accused of any wrongdoing.
It came as Ms Maxwell applied on Tuesday to a judge for a gag order to protect her “chances of a fair trial”.
Her lawyers are seeking to silence prosecutors, lawyers and federal agents, arguing that comments made since her July 2 arrest have been "prejudicial".
They would be forbidden from speaking publicly on Ms Maxwell's criminal record, the existence of any confession, the “possibility of a plea of guilty to the offense charged or a lesser offense”, as well as the identity of any of the three victims.
In a letter filed at Manhattan federal court, Jeffrey Pagliuca, Ms Maxwell’s attorney, cited public comments made by Acting US Attorney Audrey Strauss, the head of New York’s FBI office and lawyers for Ms Maxwell’s accusers.
He pointed specifically to comments made at a news conference by William Sweeney, head of New York’s FBI office, who described Ms Maxwell as “one of the villains in this investigation” and compared her to a snake that “slithered away to a gorgeous property in New Hampshire.”
She pleaded not guilty last week to charges that she recruited three girls, one as young as 14, in the mid-1990s for Epstein to sexually abuse during massage sessions she sometimes participated in at his Manhattan mansion and in Palm Beach, Florida; New Mexico; and London.
She is expected to spend a year awaiting trial at the notorious federal Brooklyn Detention Center.
The development also came a day before a judge in a civil suit filed by Ms Giuffre against Ms Maxwell was set to rule on whether to unseal documents relating to details of the socialite’s sex life.
Ms Maxwell's lawyers have tried to stop the release of 613 pages of deposition testimony the heiress gave in the case in 2016.
In refusing to unseal those documents last year, US District Judge Robert Sweet said public access would defeat privacy interests and “promote scandal arising out of unproven potentially libelous statements.”
On Thursday, Judge Loretta Preska will decide whether or not to let the files become public.