"Any aggression or military action against Iran is an idiocy whose repercussions would hurt all," government spokesman Gholam Hossein Elham told reporters.
"I don't think that such craziness and nonsense will prevail or is do-able militarily," he added.
Iran has repeatedly vowed a crushing response to any aggression against its soil and an aide to the supreme leader Ayatollah Ali Khamenei warned on Saturday that Iran would target US bases and Israel if it is attacked.
"If America and Israel shoot any bullets and missiles against our country, Iranian armed forces will target the heart of Israel and 32 US bases in the region before the dust from this attack has settled," the Fars news agency quoted Mojtaba Zolnoor as saying.
The United States and its top regional ally Israel have never ruled out attacking Iran over its nuclear drive, which the West fears could be aimed at making nuclear weapons.
There has been concern an attack against Iran could be imminent after it emerged Israel had carried out manoeuvres in Greece that were effectively practice runs for a potential strike against Iranian nuclear facilities.
Tensions over the nuclear standoff have surged again in recent days after Iran test-fired a broadside of missiles -- including one it says brings Israel within range -- in war games that provoked international concern.
Iranian Foreign Minister Manouchehr Mottaki has also warned that if the United States or its regional ally Israel attack Iran, "then our response to them will be harsh and devastating."
On Wednesday, Tehran said it test-fired its Shahab-3 missile -- the longest-range weapon in its arsenal -- and eight other missiles, adding it fired more missiles on Thursday in land manouevres at night and naval war games by day.
Mottaki described the missile firing as a show of "Iran's capabilities and ability in the military field."
Meanwhile, diplomatic efforts aimed at solving the five-year nuclear standoff have also continued.
World powers last month presented Iran with a package aimed at ending the nuclear crisis by offering Tehran technological incentives in exchange for suspending its sensitive uranium enrichment programme.
Iran has proposed its own package -- a more all embracing attempt to solve the problems of the world including the nuclear standoff -- and has made much of the common ground between the two proposals.
Iran's nuclear negotiator Saeed Jalili is to meet EU foreign policy chief Javier Solana -- who leads the talks on behalf of world powers -- in Geneva on July 19 in their latest effort to break the deadlock, Iranian officials said.
Elham again insisted that Iran would not give up enriching uranium, saying "no issue depriving our people of their rights can be debated. We will never accept any preconditions for negotiations."
Western powers fear Tehran could use the process to make a nuclear weapon but Iran rejects the accusations insisting its nuclear programme is aimed solely at generating energy for a growing population.
Indeed, Elham said it was the world powers who had changed their position and implied he believed they had dropped their demand for a suspension.
"They themselves have retreated from their positions and became aware that such a request (for suspension) is an illogical one. Thus they have taken a rational move," he said.
"The US position is showing that they are taking a logical path," he added, without giving further details.
However, the offer handed to Iran by Solana last month makes it clear that Iran must suspend enrichment for full negotiations on the incentives package to begin.
Iran has already responded to the offer in a document that has yet to be published but has been described by Solana as a "complicated and difficult letter that must be thoroughly analysed".