Twenty-five police officers have been sentenced to life in prison for their role in the 1992 Carandiru prison massacre that left 111 inmates dead.
The massacre, among the worst mass killings to have taken place in Latin America's notoriously overcrowded jails, inspired the formation of a powerful prison gang that carried out scores of deadly attacks on police in 2006.
Each officer was sentenced to 624 years in prison on Saturday for using deadly force to quell a fight among inmates.
The court found the officers guilty of killing 52 prisoners.
Judge Rodrigo Tellini read out the sentence reached by a seven-person jury, saying there had been a "clear abuse of power" by the police.
A lawyer for the police said they would appeal the ruling, but admitted it would be difficult to overturn the sentences.
The ruling was reached after a week-long trial, the second part of a process broken into four in which 79 military police officers are accused of killing Carandiru prisoners. The case was brought to trial in April after more than two decades of procedural delays.
At the time of the massacre Carandiru had 8,000 inmates and was the largest prison in Latin America.
Each trial segment focuses on the killings that took place on each of the four floors of the prison in Sao Paulo on October 2, 1992.
Prosecutors argue that the inmates were executed, while the defence claims police officers were being threatened and fired in self-defence.
Eighty-seven prisoners were wounded in the melee, but the police were unharmed.
Forensic evidence presented in the trial indicated that at least 90 percent of the prisoners who were killed died from gunshot wounds to the head and neck, and that many were shot while kneeling or lying down.
In the first phase of the trial, 23 police officers were found guilty and sentenced to 153 years in prison for the deaths of 13 inmates.
First Command of the Capital
The only person previously tried for the massacre was the commander, Colonel Ubiratan Guimaraes, who was sentenced in 2001 to 632 years in prison. Guimaraes, a former state deputy, appealed the sentence and was absolved. He was found in 2006 shot dead in his Sao Paulo apartment.
The Carandiru massacre is shown as key factor in the establishment of a criminal gang known as First Command of the Capital (PCC) in 1993.
From the prison, PCC bosses coordinated a series of assaults on police stations and public buildings which left more than 170 people dead and paralysed Sao Paulo for four days in May 2006.
The violence later spread to other cities, and scores of civilians suspected of criminal activity were gunned down in a subsequent wave of police reprisal attacks.
Late last year, the PCC was also blamed for a wave of police killings and bus burnings.
Carandiru prison was demolished in 2002.
With a population of 194 million, Brazil has 550,000 people behind bars in more than 1,000 jails, one of the world's largest prison populations.