Ayatollah Mahmoud Hashemi Shahrudi criticised police interrogators for extracting confessions.
"Sometimes they do some things like put a bag over the head, which resembles what the Americans do to terrorists in Abu Ghraib," he said.
He said such mistreatment was against the constitution, Islam and international legal principles.
Iran has regularly been criticised by international human rights groups for a range of human rights abuses and its tough penal system.
BBC correspondent in Tehran, Frances Harrison, says this is not the first time Ayatollah Shahrudi has criticised the behaviour of the security forces, but it is certainly his most outspoken attack.
His remarks, made at a conference of state prosecutors, were reported in Iranian media on Thursday.
"It is no joke to detain and hurt people's dignity and reputation," he said.
He accused police of issuing summons and carrying out interrogations without proper referral to the judiciary.
"Do not give officers carte blanche to make dossiers. This is against the law," he said.
"Interrogation is the job of the judge. A confession that is not made before a judge is void and is not a confession," he said.
The ayatollah also warned police against being too harsh on Iranians who failed to meet the country's strict dress code, especially in the coming summer months.
"Bad veiling will not be fixed by detention," he said.
"There are tens of civil ways to combat such corruption."