Mr Ahmadinejad was addressing a televised press conference
Anyone placing sanctions on Iran would be "regretful", President Mahmoud Ahmadinejad said on Tuesday.
Earlier Russia had indicated it considered sanctions against Iran were still an option if Iran did not co-operate with the UN's nuclear watchdog.
But Mr Ahmadinejad said talks were still under way and possibility for agreement "was not closed".
He also attacked the US Secretary of State for suggesting Iran is becoming a military dictatorship.
"If anyone does anything against Iran, then our response won't be the same as in the past. No, we will definitely react and make them regretful," the president told a televised press conference.
Earlier the Saudi Foreign Minister indicated his country would prefer a "more immediate solution" to the situation rather than slow-acting sanctions, but did not elaborate.
Clinton says Iran in 'turmoil'
In an interview with the BBC's Kim Ghattas, US Secretary of State Hillary Clinton appealed indirectly to the Iranian people not to let their country become a military dictatorship.
"You can be adversarial towards the US but still not want to see your country with its history and culture heading in that direction," she said.
Mrs Clinton's words appear to suggest that the Obama administration is seeking to exploit divisions inside Iran, says our correspondent.
The five permanent members of the UN Security Council plus Germany, known as the P5+1, have said Iran must agree to swap their nuclear material for enriched uranium in a controlled process if they want to continue with their nuclear programme.
Iran has said it will agree to swap their material for French nuclear isotopes, instead of enriching their own, but they insist the swap is done in Iran's territory.
The US and its allies fear Iran is attempting to develop a nuclear weapon. Iran insists its nuclear programme is entirely peaceful.
Last week the Iranian Presidency announced it had begun enriching uranium to 20%, more than they have done so before.
On Tuesday Mr Ahmadinejad said this material was not part of "the nuclear programme".
Kim Ghattas, BBC News, Riyadh
The Saudi foreign minister did not openly back Washington's call for sanctions, but neither did he say Saudi Arabia was opposed to it. He made clear the kingdom wanted a more immediate resolution to the problem rather than a gradual one.
He also said China, a top importer of Saudi oil, did not need to be prodded by Saudi Arabia to know what it ought to do about sanctions against Iran.
Saudi officials are known for using very careful, often opaque, diplomatic language. It sounded as though he was saying the kingdom would not use oil as an incentive to prod China to back UN sanctions against Iran.
But the statement could also be read as a veiled warning - if China failed to back UN sanctions, it risked upsetting its top oil supplier.
Iran says it needs the 20% enriched uranium for hospital use.
Earlier, Russia said Iran should improve its co-operation with the UN nuclear body the International Atomic Energy Agency and allay fears that its nuclear programme is for military use.
"The international community must be sure that Iran's nuclear programme is peaceful. But if these obligations are not fulfilled then nobody can rule out the use of sanctions," said Kremlin spokeswoman Natalya Timakova.
Turkey is currently holding discussions with Iran on the possibility of getting an agreement where Iran's nuclear material could be stored in Turkey.
On Monday Saudi Arabia's Foreign Minister said imposing more sanctions on Iran over its nuclear programme would not be a quick enough solution.
He spoke in Riyadh alongside US Secretary of State Hillary Clinton, who earlier said Iran was "becoming a military dictatorship".
On Tuesday, Turkey's foreign minister is due in Iran aiming to mediate.
Turkey is a Nato member, and Ahmet Davutoglu is expected to try to promote a deal on Tehran's nuclear programme between Turkey's western allies and Iran's Islamic government.
On Monday Mrs Clinton said the government of Tehran was being "supplanted" by the Iranian Revolutionary Guards Corps, and was in danger of becoming a "military dictatorship".
"We see that the government of Iran, the supreme leader, the president, the parliament, is being supplanted and that Iran is moving toward a military dictatorship. That is our view," Mrs Clinton said on her maiden visit to the kingdom.
Mr Ahmadinejad said her comments were "not wise".
He said the US spent much more on the military than Iran did, and was involved in three wars around the world.
This page is best viewed in an up-to-date web browser with style sheets (CSS) enabled. While you will be able to view the content of this page in your current browser, you will not be able to get the full visual experience. Please consider upgrading your browser software or enabling style sheets (CSS) if you are able to do so.