The New Mexico Supreme Court has unanimously ordered arrest records expunged for 32 people who were jailed overnight because a state judge said they were screaming during a hearing for a convicted rapist.

Chief Justice Edward Chavez said Tuesday that the court will publish a formal opinion on the case of state District Judge Sam Sanchez, stressing that judges should know it's important to distinguish between crowd control and contempt proceedings.

Sanchez, a judge of 11 years, had ordered the Nov. 19 mass jailing after he said the court gallery became unruly when he refused to reconsider a convicted rapist's 12-year prison sentence. The spectators were in support of a reduced sentence.

Those found in contempt of court spent a night behind bars before the state Supreme Court granted an emergency writ to release them pending a Nov. 23 hearing. Sanchez dismissed the charges at that hearing.

Sanchez apologized to the justices but said he had to control people in the gallery that he claimed were "yelling and screaming" at him and the rape victim.