Amateur video appearing to show protests after Friday's prayers
Former Iranian President Ali Akbar Rafsanjani has called for the release of people jailed after protesting at the result of the recent election.
In his first Friday sermon since the vote, he also said large numbers of Iranians still doubted its result.
Outside, police fired tear gas at thousands of opposition supporters who were chanting slogans in support of defeated candidate Mir Hossein Mousavi.
Chanting also broke out among some of the tens of thousands of people inside.
Thousands of opposition supporters rallied in streets near the university - the first public opposition demonstration for more than a week.
Many were wearing green bands on their heads or wrists to indicate support for Mr Mousavi, and some could be heard chanting "death to the dictator" and "Allahu Akbar" [God is great].
"Police fired teargas and beat supporters of Mousavi in Keshavarz Boulevard," said one witness quoted by Reuters.
Witnesses said a number of people were arrested, including a prominent women's rights activist, Shadi Sadr.
Friday's rally followed warnings from a minister against turning the occasion into a "stage for undesirable scenes".
Mr Mousavi, who attended the Friday prayers at which Mr Rafsanjani spoke, has demanded a re-run of the vote and described the new government as illegitimate.
Another defeated opposition candidate, Mehdi Karoubi, also attended the prayers, according to the website of his party, Etemad Melli.
The site quoted his son as saying that Mr Karoubi had been jostled and insulted as he arrived at the university, causing his turban to fall off.
The reports could not be immediately confirmed.
Foreign media organisations including the BBC are subject to severe restrictions.
Mr Rafsanjani is a key power-broker in Iranian politics and has been a backer of Mr Mousavi.
During his sermon, broadcast live on state radio, he said something had to be done to allay people's doubts about the recent election result.
Tehran University sermon
"In the current situation it is not necessary for us to have a number of people in prisons... we should allow them to return to their families," Mr Rafsanjani said.
"We are all members of a family. I hope with this sermon we can pass through this period of hardships that can be called a crisis."
Mr Rafsanjani also appealed for an open debate on radio and TV about the disputed 12 June election and called for media restrictions to be eased.
"It is not necessary to pressure media. We should allow them to work freely within the law," he said.
The hall was reportedly packed with opposition supporters who shouted "freedom, freedom" during the sermon. Many had green prayer mats.
The former president's comments came very close to a direct challenge to Supreme Leader Ayatollah Ali Khamenei, says the BBC's Tehran correspondent Jon Leyne, who was ordered out of Iran last month.
It was the first time in two months that Mr Rafsanjani had led weekly prayers at Tehran University.
Although he did not voice his opinion during the unrest that followed the election, members of his family - including his daughter Faezeh - openly supported Mr Mousavi.
Police fired tear gas to break up protesters outside the university
Violent street protests broke out in Iran last month, as news of President Mahmoud Ahmadinejad's victory was met with accusations of fraud.
At least 20 people have died and hundreds have been arrested in the unrest.
Ayatollah Khamenei, Iran's most senior political figure, upheld Mr Ahmadinejad's landslide victory and demanded an end to protests.
Despite this, Mr Mousavi has remained defiant.
Announcing his decision to attend Friday prayers, Mr Mousavi said on his website, "I feel obliged to respond to the call of companions on the path to protecting rights to a noble and free life".
It could be a key moment in the confrontation between Mr Ahmadinejad's government and members of the opposition, our correspondent says.
Intelligence Minister Gholam Hossein Mohseni Ejehi on Thursday urged the "wise Iranian people" to be "vigilant that the Friday prayers not be turned into a stage for undesirable scenes".