News of the agreement — a result of intense, secret exchanges between American and Iranian officials that date almost to the beginning of President Obama’s term — comes at a critical moment in the presidential contest, just two weeks before Election Day and the weekend before the final debate, which is to focus on national security and foreign policy.