Iran's supreme leader on Wednesday endorsed a landmark nuclear deal reached with world powers, but warned the government to be vigilant, saying the United States cannot be trusted.

Ayatollah Ali Khamenei, who has the final say on all state matters, endorsed the deal in a letter to moderate President Hassan Rouhani that was read on state TV. Until now he had declined to publicly approve or reject the deal while expressing support for Iran's negotiators.

The agreement reached in July with the U.S., Britain, France, China, Russia and Germany would curb Iran's nuclear activities in exchange for the lifting of crippling international sanctions.

Western nations have long suspected Iran of pursuing nuclear weapons alongside its civilian program, charges rejected by Tehran, which insists its program is entirely peaceful.

The agreement has been the subject of fierce debate within Iran, with hard-liners arguing that the negotiators gave up too much ground. They also fear the agreement could lead to a broader rapprochement with the United States, which they still deride as the "Great Satan."

Iran's parliament approved the deal in two stormy sessions that saw lawmakers shout at one another and at least one hard-line parliamentarian burst into tears. Iran's constitutional watchdog, the Guardian Council, ratified the bill a week ago, marking the last legal step for official approval.

Khamenei's expression of support largely resolves the debate in favor of Rouhani's moderate camp, handing them a major victory ahead of parliamentary elections.

But Khamenei also warned that the agreement "suffers from multiple structural weaknesses and ambiguous points that can lead to present and future great harms to the country in the absence of precise and constant vigilance." He added that "any remarks saying the structure of sanctions will remain in place are considered a breach" of the agreement.

Khamenei said Iran would begin fulfilling its commitments on the redesign of a heavy-water reactor and the trading of enriched uranium for raw uranium from Russia once the U.N. nuclear watchdog closes its investigation into whether Iran's nuclear program once had a military dimension.

The International Atomic Energy Agency has been trying for more than a decade to probe whether Iran carried out a half-dozen experiments linked to the development of nuclear weapons. Iran denies ever working on such arms and says its present nuclear program is meant only to generate power and for science and medicine.

The IAEA is set to release a final assessment of the allegations on Dec. 15, which help determine whether all sanctions imposed on Tehran over its nuclear program will be lifted.