In the power circles of Tehran, where “Death to America” is regularly chanted, the idea has taken hold that Iran must eventually negotiate with President Trump, according to several people with knowledge of the shift.

These people said Iran’s leadership had concluded that Mr. Trump could be re-elected and that the country cannot withstand six more years of the onerous sanctions he has imposed.

It is a remarkable turnabout for the political establishment in Tehran, which for the past 40 years has staked its legitimacy on defiance of the United States but has been particularly hostile toward Mr. Trump.

President Hassan Rouhani of Iran teased a possible meeting with Mr. Trump earlier this week, indicating he would be willing if it would benefit Iranians.