The tweets echoed what one of Mr. Trump’s personal lawyers, Rudolph W. Giuliani, said a day earlier about the prospective Russia deal. Mr. Giuliani said that Mr. Trump’s written answers to questions posed by the special counsel, Robert S. Mueller III, were consistent with what Mr. Cohen said in court on Thursday.

“The president said there was a proposal, it was discussed with Cohen, there was a nonbinding letter of intent and it didn’t go beyond that,” Mr. Giuliani said on Thursday.

The president’s answers, submitted to the special counsel this month, have not been made public. But Mr. Cohen’s latest version of events raised questions about whether Mr. Trump had been truthful with Mr. Mueller’s team. The president’s veracity with the special counsel has taken on greater import as his team has pursued charges against a string of witnesses for lying to investigators.

At issue is how long into the presidential campaign the Moscow opportunity was under consideration — at the time, questions were swirling about Mr. Trump’s desire for friendlier ties to Russia. In 2016, Moscow was conducting a clandestine effort aimed at getting Mr. Trump elected, and Mr. Mueller is investigating whether the Trump campaign conspired in those efforts.

Speaking to reporters on Thursday as he left Washington for an economic summit meeting in Buenos Aires, Mr. Trump said Mr. Cohen was weak and had lied to prosecutors so that he could get a reduced sentence for other crimes he has pleaded guilty to.