Iran could abandon the Non-Proliferation Treaty (NPT) if forced to limit nuclear activities, its hardline president says.
Mahmoud Ahmadinejad said if the rights of the Iranian people were violated, Iran would "revise its policies".
He made the comments in a speech marking the anniversary of the 1979 Islamic revolution.
On 4 February, the IAEA decided to report Iran to the UN Security Council over its disputed nuclear programme.
The NPT, which has 187 signatories, was created to prevent new nuclear states emerging, to promote co-operation in the peaceful use of nuclear energy and to work towards nuclear disarmament.
Non-nuclear signatories agree not to seek to develop or acquire such weapons. In return, they are given an undertaking that they will be helped to develop nuclear energy for peaceful purposes.
It is believed to be the first time Iran has threatened to pull out of the treaty.
Addressing huge crowds in Tehran, Mr Ahmadinejad said that Iranian policy was based on the peaceful use of nuclear technology for "industry, medicine and economy".
"Until now the Islamic Republic has pursued its nuclear effort within the context of the International Atomic Energy Agency and the Non-Proliferation Treaty," he said.
A huge crowd turned out to listen to the president
"However, if we see that despite our respect for these regulations you want to violate the rights of the Iranian people, you should understand the Iranian nation will revise its policies," he warned.
On 6 February, following the IAEA's decision to report Iran to the UN Security Council, Iran formally told the UN nuclear watchdog to end snap inspections of its nuclear sites by mid-February.
It also ordered the IAEA to remove surveillance cameras and indicated it would end its freeze on full uranium enrichment.
Iran denies US and European claims that it is trying to develop weapons, maintaining that its nuclear programme is only for energy production.
Leaving the NPT is allowed under the treaty, and would allow a state free to develop nuclear power and weapons without inspection.
North Korea announced its withdrawal from the NPT in January 2003, the first state to make such a move.
Several states with nuclear weapons - Israel, India and Pakistan - have never joined the treaty.