"If anyone allows themselves to invade Iranian territory and its legal interests... our armed forces will break their hands before they pull the trigger," Ahmadinejad said at a military parade speech broadcast live on state television.
"Our nation is seeking friendship and peace... but today it is not in a position to show the least flexibility towards its bullying enemies," he said in the speech at the 28th anniversary of its eight-year war (1980-1988) with Iraq.
Iran is at odds with the West over its disputed nuclear programme, which the United States and its allies fear could be used to make nuclear weapons. Iran insists it only wants to produce nuclear energy.
The United States has never ruled out a military strike against the Islamic republic although Washington insists it prefers diplomacy. The same is true of US ally Israel, which Iran does not recognise.
Israel, the region's sole if undeclared nuclear armed state, considers Iran its main strategic threat because of its nuclear programme.