WASHINGTON — For a year, Obama administration officials had been meeting in secret with Iranian counterparts, seeking to free Americans imprisoned in the Islamic republic. Finally last fall, a deal for a prisoner release seemed all but sealed.

But the Iranians arrived at the latest clandestine session in a Geneva hotel suite with a whole new proposal that insisted on the release of dozens of Iranians held in American prisons, essentially returning to initial demands that had long since been rejected.

The Americans were flabbergasted. “We’ve already talked about this,” said Brett McGurk, the lead negotiator. But the Iranians were adamant, according to American officials informed about the meeting. Something back home had changed, part of the continuing battle inside Iran over how to deal with the United States. Someone in power in Tehran, it seemed, did not want a deal after all.

And so Mr. McGurk and his team picked up their papers and walked out, putting an abrupt end to the meeting. Mr. McGurk’s interlocutors had come from Iran’s state security apparatus, a group that had barely, if ever, met Americans, much less negotiated with them. They did not have the well-traveled, English-speaking demeanor of the two senior Iranians who had been negotiating the larger nuclear deal with the United States for more than two years.