Mr. Obama and Mr. Rouhani held a telephone conversation at the end of the 2013 General Assembly as the Iranian leader headed home, becoming the first leaders of their countries to speak in more than three decades and raising hopes at the time that the long-estranged relationship might improve.

Despite Mr. Trump’s antipathy toward Iran, there has always been some expectation that he would seek to engage with Iranian officials in a manner similar to how he has approached another adversary, North Korea. After a litany of bombastic threats and insults, Mr. Trump met with the North Korean leader, Kim Jong-un, in Singapore last month.

North Korea appeared to be on the mind of Mr. Vaezi in his remarks on Wednesday, in which he seemed to suggest that Mr. Kim had made a mistake.

“We have a transparent policy and clear position with regard to our relations with the U.S.,” Mr. Vaezi said. “The characteristic of this establishment and people is that they will not yield to pressure. Trump should know that Iran and its people are different from North Korea and its people.”

Some political analysts suggested that Iran’s emphasis on its rejection of Mr. Trump reflected an absolute policy of no engagement enforced by Mr. Khamenei, who has the final word on such matters and is deeply distrustful of the West — especially the United States.

“The biggest obstacle to a U.S.-Iran dialogue is not Trump but Khamenei,” said Karim Sadjadpour, a senior fellow in the Middle East program at the Carnegie Endowment for International Peace. “Trump flew halfway around the world to meet with Kim Jong-un. Khamenei hasn’t left Iran since 1989.”

Since Mr. Trump repudiated the 2015 nuclear agreement with Iran two months ago, the risks that the accord will collapse have grown.