Pro and anti-government protesters were locked out of the campus

There were scuffles as hundreds of supporters and opponents of the president gathered outside the venue.

Eyewitnesses said police used tear gas to hold the demonstrators back.

Student leaders had challenged Mr Ahmadinejad to meet them after he spoke at Columbia University in the US of the freedoms enjoyed by Iranian students.

The BBC's Jon Leyne in Tehran says all gates to the university were locked and journalists were prevented from entering.

Tear gas

But from outside two groups of demonstrators were clearly visible, each of perhaps a few hundred students, our correspondent says.

One group was made up of government supporters. Another group of opponents was chanting: "Death to the dictator."

According to eyewitnesses police used tear gas when the protesters tried to break into the hall where Mr Ahmadinejad was speaking. They also tried to prevent him leaving.

Protesters eventually dispersed once Mr Ahmadinejad left the university.

It was not a huge crowd but it was one of the first demonstrations against the government here in many months.

Mr Ahmadinejad faced similar dissent during a speech in December 2006 when students at Amir Kabir Technical University called him a dictator and set fire to his picture.

Speech omissions

It has also emerged that parts of a speech given by the president last week in the US may have been blocked by the state broadcaster, our correspondent adds.

During the speech Mr Ahmadinejad criticised those pressing for negotiations on the nuclear issue. Much of the speech was carried live but those comments were not aired.

Mr Ahmadinejad's remarks were seen as criticism of supporters of former President Hashimi Rafsanjani.

It seems that Mr Rafsanjani may have some friends in the state broadcasting network who did not want the comments to be aired, our correspondent says.