Phoenix (CNN) In his years as the top lawman in Arizona's largest county, Joe Arpaio touted the tough punishments he handed out.

Now the former Maricopa County sheriff's fate is in a judge's hands.

And if US District Judge Susan Bolton finds him guilty of criminal contempt, the man who once called himself "America's toughest sheriff" could end up behind bars.

Arpaio is accused of violating a court order in a racial profiling case by continuing patrols that targeted immigrants. The 85-year-old has said the court order wasn't clear and he didn't intend to violate it.

But in closing arguments Thursday, prosecutor John Keller alleged that Arpaio's defiance was deliberate -- and something he thought he could get away with.

"The defendant thought this day was never coming," Keller said. "But nobody gets to defy a federal judge's order."

If he's convicted, Arpaio could face up to six months in jail. The judge is expected to make a decision in several weeks.

People on both sides of the immigration debate have been closely watching the high-profile trial.

Supporters of Arpaio slam the case, which the Justice Department began prosecuting under the Obama administration, as politically motivated.

Immigrant rights advocates and other longtime critics of the outspoken former sheriff are hoping the trial ends with his conviction.

How did we get here?

Arpaio served as sheriff of Maricopa County for more than two decades. The county is home to Phoenix, the state's capital, and more than 4 million people -- about 30% of whom are Latino.

During his tenure as sheriff, Arpaio's headline-grabbing punishments earned him diehard supporters and fiery opponents. He established Tent City , an infamous outdoor jail where inmates wore pink underwear and shuffled around in chain gangs. He said he was saving taxpayers money by removing salt and pepper from jail meals.

And he made cracking down on illegal immigration a priority for his deputies -- gaining national notoriety in the process as he became a darling of conservative cable television commentators and a villain to immigrant rights activists.

JUST WATCHED 2013: Judge says Sheriff Arpaio was profiling Replay More Videos ... MUST WATCH 2013: Judge says Sheriff Arpaio was profiling 01:32

His legal troubles began in 2007, when a group of Latinos filed a class action civil lawsuit claiming that Arpaio's policing policies amounted to racial discrimination. A federal investigation and a federal civil rights lawsuit followed.

US District Judge G. Murray Snow issued a temporary injunction in 2011, blocking Arpaio's office from detaining people solely based on their immigration status. The judge issued a permanent order two years later, ruling that Maricopa County's handling of people of Latino descent amounted to racial and ethnic profiling.

Last year, the judge asked federal prosecutors to file criminal contempt charges against Arpaio and several subordinates, alleging that they'd disregarded the court's directions, made false statements and attempted to obstruct further inquiry.

Prosecutors: Arpaio held himself above the law

Nine witnesses took the stand during the eight-day trial, including Arpaio's former attorney, Tim Casey, who was questioned by the defense during the occasionally contentious testimony.

During his closing argument, Keller, deputy chief of the Justice Department's Public Integrity section, said Arpaio told the court he "understood the exact situation of how the preliminary injunction applied," but made false statements to his attorneys and federal immigration officials to defy the Obama administration.

"In the defendant's own words, he made the decision. No one was higher than him," Keller said.

The prosecution argued that Arpaio raised millions in re-election campaign funds in large part due to his widely publicized anti-federal government stance.

JUST WATCHED 2012: Arpaio won't tolerate govt. monitoring Replay More Videos ... MUST WATCH 2012: Arpaio won't tolerate govt. monitoring 01:59

Keller played an excerpt from a Fox News interview with host Neil Cavuto , which took place at the time of the temporary injunction, in an attempt to show what he asserted was Arpaio's defiance.

"If you stop a car and suspect that the occupants might be illegal ... what does Joe Arpaio do after that?" Cavuto asked.

Arpaio said: "One thing I'm going to do, if it's some sort of ... crime, they're going to jail."

In another video played in court, Arpaio, speaking to a Mexican detainee through a translator, said: "Nobody is higher than me. I am the elected official, elected by the people. I don't serve any governor or any president."

Keller said Arpaio "continued to detain people all the way up until May 2013."

Defense: 'Nobody thought they were violating the order'

But defense attorney Dennis Wilenchik claimed Arpaio was unaware his officers were doing anything unlawful. He argued Arpaio didn't lie to his former attorney, Casey, about stopping the detentions.

Rather, Wilenchik said Casey "dropped the ball" and didn't clearly explain the order or seek clarification from Snow. "I'm not here to cry or castigate him. But he is at fault," Wilenchik said of Casey.

Wilenchik re-read testimony from the first day of the trial, when he questioned Casey.

"Let me ask it this way," Wilenchik said then. "Did you believe when you read that (preliminary injunction) that it was clear to you?"

JUST WATCHED 2012: Stats don't support profiling, Arpaio says Replay More Videos ... MUST WATCH 2012: Stats don't support profiling, Arpaio says 03:25

"I thought that there was ambiguity," Casey said.

"If he thought it was ambiguous, why wouldn't a good lawyer seek clarification from the court before exposing his client to a possible contempt?" Wilenchik told Bolton.

Wilenchik said the only person who knew what Snow meant in his order "was Judge Snow himself."

"Nobody thought they were violating the order, but I think it's easy to understand why the sheriff was singled out here," Wilenchik said, claiming the prosecution is driven by politics.

He challenged the prosecution's notion that Arpaio used his defiance of the order to raise money for his own re-election.

Arpaio's fall from grace

In November, Arpaio lost his bid for a seventh term to Paul Penzone, a former Phoenix police officer.

JUST WATCHED 2016: Paul Penzone beats controversial Arizona Sheriff Arpaio Replay More Videos ... MUST WATCH 2016: Paul Penzone beats controversial Arizona Sheriff Arpaio 01:05

Arpaio's opinions and actions drew praise and rebuke during his 24-year run as sheriff. He insisted President Barack Obama was not an American citizen and that his birth certificate was fraudulent -- a claim that has been debunked.

In 1993, he established Tent City -- the infamous outdoor jail. Arpaio said the outdoor jail saved taxpayers money despite criticism that the facility was inhumane.

This spring, Penzone announced he was taking down the tents and closing the desert camp, saying there was no evidence that it deterred crime.

"This facility became more of a circus atmosphere for the general public," Penzone said. "Starting today, that circus ends."