Prince Andrew, Duke of York, Donald Trump posing for the camera: President Trump, Melania Trump and Prince Andrew, left, during a tour of Westminster Abbey in London in June. © Pool photo by Stefan Rousseau President Trump, Melania Trump and Prince Andrew, left, during a tour of Westminster Abbey in London in June.

LONDON — President Trump denied on Tuesday that he knew Prince Andrew, the son of Queen Elizabeth II who has become entangled in sexual abuse accusations against the disgraced financier Jeffrey Epstein.

“I don’t know him, no,” the president told reporters gathered in London for the NATO summit.

But photographs show they have met several times over the past 20 years, and as recently as June when the prince, known formally as the Duke of York, hosted a breakfast meeting for Mr. Trump during his state visit to Britain. Those photos were posted on the prince’s Twitter account.

Sign Up For the Morning Briefing Newsletter

Mr. Trump also toured Westminster Abbey in London with the prince, and they were photographed laughing together.

The prince announced last month that he was stepping back from public life after a disastrous television interview in which he tried to defend his connection to Mr. Epstein and said he had no recollection of Virginia Roberts Giuffre, who has testified that she was ordered to have sex with the prince.

Ms. Giuffre, who has also spoken publicly about being abused by Mr. Epstein, reiterated the accusations in a British television interview of her own on Monday. The prince has denied any wrongdoing in his interactions with Mr. Epstein, who was jailed for 13 months in 2008 on a charge of soliciting prostitution from a minor. The financier hanged himself in a Manhattan jail in August while awaiting trial on new sex-trafficking charges.

Donald Trump, Prince Andrew, Duke of York are posing for a picture: Mr. Trump with Prince Andrew in June. © Jeff Mitchell/Getty Images Mr. Trump with Prince Andrew in June.

Mr. Trump has sometimes sought to distance himself from people whom it has become painful or perilous to discuss, including Matthew G. Whitaker, his rejected choice for attorney general; and Gordon D. Sondland, his ambassador to the European Union.

Earlier photos also show Mr. Trump together with the prince, the queen’s third child.

Mr. Trump and his then-girlfriend, Melania Knauss — now the first lady — were seen with the prince at least twice in 2000: once at the opening of Hudson Hotel in New York and, more intimately, at Mr. Trump’s Mar-a-Lago estate in Florida.

Mr. Trump also told reporters on Tuesday that he did not know anything about Jeremy Corbyn, the main rival of Prime Minister Boris Johnson in the upcoming election.

“Jeremy Corbyn?” Mr. Trump said. “Know nothing about him.”

But the president had given an opinion on Mr. Corbyn as recently as last month, on a London-based radio show.

“Corbyn would be so bad for your country, he’d be so bad, he’d take you in such a bad way,” Mr. Trump said. “He’d take you into such bad places.”