The telephone line had been secretly set up. President Trump waited on the other end. All President Hassan Rouhani of Iran had to do was come out of his hotel suite and walk into a secure room where Mr. Trump’s voice would be piped in via speaker.

Mr. Rouhani and his aides were blindsided by the offer, presented to them by President Emmanuel Macron of France on an unannounced visit last Tuesday night to their quarters at the Millennium Hilton New York One UN Plaza hotel near the United Nations, where world leaders had converged for the annual General Assembly.

It was a mission lifted out of a Hollywood thriller. Mr. Macron has sought for months to broker a thaw in the standoff between the United States and Iran, which has threatened to escalate into a new Middle East war.

Accompanied by a small team of advisers, Mr. Macron awaited an answer outside the Iranian leader’s suite, according to three people with knowledge of the diplomatic gambit, which was first reported on Monday by The New Yorker. Messages were passed between them via Mr. Rouhani’s aides.