In December last year, a similar incident occurred during a speech when students at Amir Kabir Technical University called him a dictator and set fire to his picture.
On Monday organisers checked the identity papers of all students entering the university, allowing only selected students into the hall where Ahmadinejad spoke.
Ahmadinejad was subjected to blistering criticism of his country's human rights record and foreign policy when he spoke at Columbia University in New York city last month.
The Iranian president was met with protests on the streets and Lee Bollinger, the university's president, called him "a petty and cruel dictator" and "simply ridiculous".
On Monday Ahmadinejad said the incident at Columbia was an America attempt at propaganda gone wrong.
"They had planned to use this incident for propaganda in the international community and prepare the ground for violating Iran's rights. Three or four hours after my speech in Columbia University they realised that they were in trouble and they admitted they had failed in their plans and had made a mistake," he said.
Students were once the main power base of Iran's reform movement but have faced intense pressure in recent years from Ahmadinejad's government, making anti-government protests rare.
In recent months the government has detained hundreds for allegedly threatening the Iranian system and shut down numerous pro-reform newspapers.
At universities, pro-reform students have been marginalised and now only hold low-level meetings and occasional demonstrations, usually to demand better school facilities or the release of detained colleagues.
Ahmadinejad's popularity at home has fallen since he was elected, with critics saying he has failed to fix the economy and has tarnished Iran's international image.
He is accused of failing to keep his campaign promises to bring oil revenues to every family, eradicate poverty and tackle unemployment.
Instead, prices of houses, food and other commodities have soared.