WASHINGTON — The United States and Iran are closing in on a historic agreement to limit Iran’s nuclear program, but are confronting serious last-minute obstacles, including when United Nations sanctions would be lifted and how inspections would be conducted, American and European officials said.

Secretary of State John Kerry, who heads to Lausanne, Switzerland, on Sunday night for a critical round of talks, is still clashing with his Iranian counterpart over Tehran’s demand that all United Nations sanctions be suspended as soon as there is a deal, as well as Washington’s insistence that international inspectors be able to promptly visit any nuclear site, even those on Iranian military bases.

There are also disagreements over Iran’s research and development of advanced centrifuges, which would allow Iran to produce nuclear fuel far more quickly, as well as over how many years an agreement would last.

The White House hopes that an accord might eventually open a new chapter in a relationship that has been marked largely by decades of mutual suspicion, Iranian-sponsored terrorism, American cyberattacks and Iranian retaliation. But even the prospect of the deal has set off a furious political confrontation between the White House and Republicans who say an accord will fail to end Iran’s bomb program and even encourage Arab nations to mount their own nuclear efforts. Former Secretary of State Henry Kissinger told Congress recently that the effect of the emerging deal with Iran would be “to move from preventing proliferation to managing it.”