PHOENIX (CN) — Joe Arpaio bragged to news media about enforcing federal immigration law while he was Maricopa County sheriff, even after a federal judge ordered him to stop, prosecutors said Monday as Arpaio’s trial began for criminal contempt of court.

The Department of Justice charged Arpaio with refusing to abide by a federal judge’s order in a racial profiling class action. The federal courtroom was packed Monday for opening statements from federal prosecutors and Arpaio’s attorneys.

Arpaio, 85, a Republican, served as Maricopa County sheriff for 24 years until he was voted out of office in November. He called himself America’s toughest sheriff.

Victor Salgado, an attorney with the Department of Justice’s Public Integrity Section, said evidence will show that though Arpaio was warned about complying with court orders, “He wore his defiance.

“The court issued a clear and definite order, the defendant knew of the order, and the defendant willfully violated the order,” Salgado said.

Salgado read statements Arpaio made to news media after U.S. District Judge G. Murray Snow issued a preliminary injunction in December 2011, in the class action alleging that Arpaio and his deputies racially profiled Latinos during traffic stops.

Arpaio is charged with violating Snow’s order from Dec. 23, 2011 through May 24, 2013.

Just days after the court order was issued, Arpaio issued a statement saying: “I will continue to enforce illegal immigration laws.”

In April 2012, he told PBS NewsHour: “Nobody is higher than me. I am the elected sheriff by the people. I don’t serve any governor or president. … I serve the people.”

He continued: “I’m still gonna do what I’m doing.”

Salgado said Arpaio bragged about his “contemptuous acts to the press” to garner “the news headlines that he craved and the votes that he needed to get elected.”

According to the Department of Justice, Arpaio’s office detained, arrested and transferred about 170 people to Immigration and Customs Enforcement in violation of Snow’s order. Arpaio has acknowledged his contempt in the civil case.

Arpaio’s attorney Dennis Wilenchik told the court it was “shameful” to suggest that “a bunch of glib clips” are relevant to the case.

“The quotes that were shown to you were misleading to say the least,” Wilenchik told U.S. District Judge Susan Bolton. “None of these clips that were read to you in any way show proof, let alone beyond a reasonable doubt that the sheriff was not going to follow” the law.

Wilenchik said Arpaio’s deputies were within their legal right to call Customs and Border Protection or ICE if they picked up an undocumented immigrant during a traffic stop.

“The sheriff was following those laws that this injunction had nothing to do with,” Wilenchik said.

If the order was misinterpreted, Wilenchik said, it was due to the actions of Arpaio’s former counsel, Tim Casey.

“Mr. Casey was the primary person entrusted with the authority to get all this stuff done,” Wilenchik said. “(He) completely dropped the ball, gave no guidance.”

Wilenchik said that Judge Snow’s order was neither clear nor definite.

“This case is ridiculous, and it is an assault on our logic collectively to assert that the sheriff ever, ever intended to disobey any court order,” Wilenchik said.

Casey, who served as an attorney for Arpaio and Maricopa County from 2007 through 2014, was the first witness called by the Justice Department.

Almost every question that Department of Justice attorney John Keller asked Casey was objected to by Wilenchik and Karen Clark, ethics counsel for Casey, who claimed attorney-client privilege.

Despite the objections, Keller tried to build a case to show Arpaio’s contempt.

“He knew about the order,” Casey testified. “I wanted to make sure he understood that he could not detain.”

Casey said he repeatedly checked in with Arpaio and Arpaio’s executive staff at the Sheriff’s Office to make sure that the order was explicitly understood.

After the Ninth Circuit ruled on an interlocutory appeal, Casey emailed copies to Arpaio’s staff.

“It doesn’t change the injunction, it doesn’t do anything,” Casey said he told them.

In another instance, Casey forwarded a letter he received from Andre Segura of the American Civil Liberties Union, alleging that Arpaio’s deputies were improperly detaining immigrants during traffic stops for the Border Patrol to pick up. Arpaio was not copied on the email, however.

“He does not use email,” Casey testified.

In a September 2012 news release, Arpaio was quoted as saying he had a “backup plan in place, which was to take these illegal immigrants not accepted by ICE to the Border Patrol.”

Casey said: “I told the sheriff that in my judgment it was likely, not definitively, a violation.”

Keller asked: “What did the sheriff say after you talked to him about the press release?”

Casey replied: “He’s the sheriff. He makes the decisions.”

Casey said that after a heated conversation, Arpaio told him it wouldn’t happen again.

“He characterized it as a mistake,” Casey said. “To my knowledge it didn’t happen [again] from that point until I withdrew.”

Wilenchik asked Casey why he did not write to the ACLU that it was a mistake by sheriff’s deputies to detain undocumented immigrants.

“You thought that there could have been a misunderstanding of some kind,” Wilenchik said. “To be clear, you didn’t in your response tell the plaintiffs at any point of time.”

Casey said such a statement would have violated attorney-client privilege.

Wilenchik said Casey appeared “defensive” on the stand Monday.

“I think you know why I’m defensive,” Casey responded.

The trial is expected to last two weeks.