PHOENIX (AP) — The immigration rhetoric and crackdowns pushed by President Donald Trump have a familiar ring in Arizona, where former Sheriff Joe Arpaio once used similar tactics to become a national figure.

Now, Arpaio is going on trial on a criminal charge stemming from those immigration enforcement actions.

The eight-day trial that begins Monday in federal court in Phoenix will determine whether the 85-year-old retired lawman is guilty of misdemeanor contempt of court for disobeying a judge’s order to stop traffic patrols that targeted immigrants. The judge later found his officers racially profiling Latinos.

Arpaio’s legal troubles played a major role in voters turning him out of office in November after a campaign in which he appeared alongside Trump at several rallies in Arizona.

The former six-term sheriff of metro Phoenix has acknowledged defying the judge’s 2011 order in a racial profiling lawsuit by prolonging the patrols for months. But he insists it was not intentional. To win a conviction, prosecutors must prove he violated the order on purpose.

If convicted, Arpaio could face up to six months in jail, though lawyers who have followed his case doubt that a man of his age would be put behind bars.

For nine of his 24 years in office, Arpaio did the sort of local immigration enforcement that Trump has advocated. To build his highly touted deportation force, Trump is reviving a long-standing program that deputizes local officers to enforce federal immigration law.

Unlike other local police leaders who left immigration enforcement to U.S. authorities, Arpaio made hundreds of arrests in traffic patrols that sought out immigrants and business raids in which his officers targeted immigrants who used fraudulent IDs to get jobs.

His immigration powers were eventually stripped away by the courts and federal government, culminating with the 2013 ruling that Arpaio’s officers profiled Latinos.

Arpaio’s defense centers around what his attorneys said were weaknesses in the court order that failed to acknowledge times when deputies would detain immigrants and later hand them over to federal authorities.

Jack Wilenchik, an Arpaio attorney, said the former sheriff is charged with a crime for cooperating with U.S. immigration officials, which the Trump administration now encourages.

“This is really just a fight about immigration law and what it means,” Wilenchik said. “And Arpaio is trying to do what a good cop does, which is to enforce the law.”

His critics hope the case will bring a long-awaited comeuppance for the lawman who led crackdowns that divided immigrant families and escaped accountability.

The judge concluded that Arpaio ignored the order because he believed his immigration enforcement efforts would help his 2012 campaign. The TV interviews, news releases and tough talk about America’s border woes that Arpaio used over the years to boost his popularity are now being used against him in court.

The sheriff’s office issued a news release a week after the judge told it to stop the patrols saying it would continue to enforce immigration laws. Arpaio also gave a March 2012 TV interview in which he said his office was still detaining immigrants who were in the country illegally.

The retired lawman lost a request to prohibit prosecutors from mentioning comments he made about immigration during his last three campaigns.

It’s not known whether Arpaio will testify in his defense.