"Progress has happened in various fields... but in the field of justice we acknowledge that we have lagged behind," Khamenei said in a speech in Tehran, which was published on his website.
He said it was necessary to apologise to God and the people of Iran for this failure.
Khamenei was marking the 40th anniversary of an uprising in the city of Tabriz that was a key moment leading up to the 1979 Islamic revolution.
Iran has foiled plot to use protests to overthrow system: Khamenei
He acknowledged the widespread anger exposed by a week of rioting and protests across Iran over the new year, but he said people were still firmly behind the revolution.
"Of course people have criticisms of some current issues in the country and we are fully informed about complaints," Khamenei said.
"But when it comes to the question of the revolution and the system, people come out and defend them."
The conservative-dominated judicial system has been frequently criticised by rights activists for targeting political opponents, arbitrary detentions, violence against inmates and having the highest per capita rates of execution in the world.
Trump will fail against Iran as did 'smarter' Reagan, says Khamenei
Its behaviour has returned to spotlight in recent days after a renowned environmentalist, Kavous Seyed Emami, "committed suicide" in prison after being arrested on espionage charges.
His family say they were threatened with violence if they discussed the case.
That followed allegations that two people had died in prison last month after being arrested as part of the crackdown on the protests.
The authorities say their arrests were unconnected to the protests and that they, too, committed suicide.
COMMENTS
Comments are moderated and generally will be posted if they are on-topic and not abusive.
For more information, please see our Comments FAQ