FLORENCE, Ariz. (AP) — Three Pinal County jail inmates have been sentenced to life in prison for attacking and plotting to kill a detention officer who was stabbed over 20 times with sharp instruments made inside the jail.

Law enforcement officers filled the courtroom Thursday as Robert Villalobos, 30, Santiago Sanchez, 27, and Mauricio Moraga 27, received their punishment. A jury in August convicted them of conspiracy to commit murder and other charges stemming from the 2016 attack on then-Lt. Sergio Antolin.

The three are accused of targeting Antolin because he was responsible for investigating the jail's gang population, the Casa Grande Dispatch newspaper reported.

Court documents indicate the defendants have ties to the Arizona Mexican Mafia prison gang, and prosecutor Patrick Johnson said the trio believed they were attacking Antolin on its behalf.

Johnson said the crowded courtroom showed that the law enforcement community is united and wasn't intimidated by the attack. Antolin has recovered from his injuries and retired from his jail job.

Sanchez and Moraga were already serving prison sentences for other convictions.

Moraga pleaded guilty to manslaughter after he crashed a truck and killed a 19-year-old Casa Grande woman in 2015. Sanchez was convicted of a drive-by shooting in 2011 and was sent back to prison a few years later after he violated his probation.

Villalobos is awaiting trial in Pinal County for a number of charges.

The guard who was attacked said he knew all three defendants well through their interactions at the jail and was surprised they tried to kill him. Detention officers strive to treat all inmates with respect, Antolin added.