The count of arrests was dramatically higher than authorities' earlier reports, which had only 520 people, mostly "hooligans" as a result of the June 10-14 protests against the hard-line clerics.
Among the 4,000 arrested were about 800 students and 30 key student leaders, Iran's prosecutor general, Abdolnabi Namazi, said, according to the state-run daily Iran.
Namazi said about half of those detained were almost immediately freed, while some 2,000 remained in jail, the paper reported Saturday.
"The confirmation of 4,000 arrests shows how insincere the rulers are and how the crisis has deepened in Iran," student leader Saeed Allahbadashti told The Associated Press.
The protests, which were the largest in months, began as student demonstrations against plans to privatize universities and snowballed into broader displays of opposition to Iran's hard-line clerical establishment, led by supreme leader Ayatollah Ali Khamenei.
On June 16, More than 250 university lecturers and writers called on Khamenei to abandon the principle of being God's representative on earth and to accept he is accountable to the people. The ruling clerics regard Khamenei as God's representative and that his word cannot be challenged.
The demonstrations largely ended after the deployment of hundreds of security forces and unleashing of pro-clergy thugs armed with knives and batons to attack protesters.
Allahbadashti, one of few student leaders not imprisoned during the protests, said the establishment has lost its legitimacy through its crackdown on the protests.
"The judicial authorities are openly lying to the nation. First, they said few hooligans have been arrested. Now, they confirm the arrest of 800 students. They are buying only greater hatred from the people whose call for change has been ignored," he said.
Meanwhile, authorities are trying to prevent a new round of student protests to mark the fourth anniversary of a July 9, 1999 attacks on Tehran University dormitories by pro-clerical militants.
Those attacks killed one student, injured at least 20 others and triggered six days of nationwide anti-government protests, the worst since the 1979 Islamic revolution that toppled the pro-U.S. Shah Mohammad Reza Pahlavi.
Authorities have banned any marches to remember the raid. "An incident took place a few years back and there is no necessity to mark the anniversary," the Iran quoted Namazi, the prosecutor, as saying.
Students have vowed to defy the ban and warned that their accumulated wrath was about to explode.
Protesters have long focused their anger toward Iran's unelected hard-line clerics, while supporting President Mohammad Khatami, who was elected by a landslide on promises of delivering social, political and economic reforms.
But this month's student-led protests not only called for the conservative establishment's ouster but also denounced Khatami for failing to fulfill his promises.
Political analyst Mostafa Kavakebian said the government's iron-fisted approach to dealing with pro-reform students would make matters worse.
"History shows that use of force against civil protests only backfires. It's not logical for the establishment to get harsh with students," said Kavakebian, who also heads a reformist political party.