Mahmoud Ahmadinejad's remarks on Wednesday came hours after George Bush, the US president, delivered his State of the Union address and a day before the UN nuclear agency is likely to vote to put Iran before the Security Council.
In a speech in Bushehr in southern Iran, the site of the country's only nuclear power plant, Ahmadinejad said that the US is "tainted with the blood of nations" and led by a man who became president through a court ruling.
Referring to Iran's nuclear programme, he said: "Our nation will continue its path until full realisation of its rights, nuclear energy is our right, and we will resist until this right is fully realised."
The crowd of thousands responded with chants of "Nuclear energy is our right!"
In his address on Tuesday night, Bush had said "the nations of the world must not permit the Iranian regime to gain nuclear weapons".
Mostafa Mohammad Najjar, Iran's defence minister, warned all countries against considering attacks on Iran's nuclear installations.
"Nuclear energy is our right, and we will resist until this right is fully realised."
"Any attack against Iran's peaceful nuclear facilities will meet a swift and crushing response from the armed forces," he said.
Iran's defence priority was to "strengthen the operational might of the air force against any possible threat", he said in Bushehr.
The nuclear power plant in Bushehr is having the finishing touches put to it by Russia.
The International Atomic Energy Agency's 35-nation board of governors is to meet in Vienna, Austria, on Thursday, and is expected to report Iran's nuclear programme to the Security Council.
The Council reached a surprise agreement on Tuesday when it decided that Iran should be hauled before that powerful body over its disputed nuclear programme.