For most of Joe Arpaio’s two-plus decades as Maricopa County sheriff, he directed operations from the top floor of a downtown Phoenix tower, worlds away from the jails overseen by rank and-file deputies. The executive offices wrapped around an expansive conference room, where I spent weeks in early 2008 with banker boxes full of arrest records, and hanging out with Arpaio himself, a politician who built his career on bashing immigrants long before the rise of Donald Trump.

Back then, I was working for the East Valley Tribune, then a daily newspaper in the Phoenix area. I had filed a public records request for all documents from deputies’ immigration operations. Teamed with Paul Giblin, a fellow Tribune reporter, we were trying to figure out how the sheriff was enforcing immigration laws, and what effect their monomaniacal focus was having on regular police work — like solving crimes. Arpaio had long before achieved national notoriety for making prisoners wear pink underwear and housing them in an outdoor tent city so hot that the inmates’ shoes melted.

The sheriff’s office had spent the previous year carrying out a constitutionally dubious dragnet search for undocumented immigrants. Patrol deputies became expert at inventing pretexts for stopping the “load cars” that ferried immigrants through the county to points across the nation. Sheriffs descended on neighborhoods where day laborers waited for people willing to pay for their work. Voters repeatedly re-elected Arpaio as he carried out his pledge to transform the sheriff’s office into “a full-fledged anti-illegal immigration agency.”

The final chapter of this story is playing out now on the national stage.

Last month, federal Judge Susan Bolton found Arpaio guilty of criminal contempt of court. In December 2011, another federal judge ordered the sheriff’s office to stop detaining people based solely on their immigration status. The agency ignored the judge’s ruling and went right on targeting immigrants. Arpaio, who lost his bid for a seventh term as sheriff in November, testified that he had no idea his deputies were blatantly violating the order. Judge Bolton decided he was not telling the truth. As she concluded in her written opinion, Arpaio had demonstrated a “flagrant disregard” for the court order.

Arpaio, 85, is scheduled to be sentenced on Oct. 5, with a maximum potential penalty of six months in prison. That is the plan, unless President Donald Trump intervenes.

On Sunday, as much of the nation fixated on the events in Charlottesville, the president told Fox News that he is “seriously considering” issuing a pardon to Arpaio. The former sheriff campaigned for Trump throughout 2016, shares his views on immigration and, in the past, was a supporter of Trump’s efforts to raise doubts about former President Obama’s birth certificate.

Trump and Arpaio share more than one trait. They both rose to national prominence as showmen who cannily worked the press to their advantage. Over time, their media relationships eventually mutated into more combative interactions with parts of the media, and both Trump and Arpaio took to engaging in periodic press-bashing. But all those years ago, Arpaio did not treat me as an enemy.

After submitting the records request on Dec. 31, 2007, I braced for the kind of belligerent rejection local reporters had often received from the sheriff’s office, and the months of legal struggle to come. Instead, Arpaio’s public affairs team invited us to come by and handed over thousands of pages of unredacted records. They were pleased the press wanted to write in detail about how many undocumented immigrants the agency was arresting.

As we worked our way through the files over the succeeding weeks, Arpaio would pop into the conference room each day, sometimes to say hello. Just as often, he came to hang out. To banter. To try out the wording of press statements before releasing them to the rest of the media. One day, he asked us how we’d respond if he announced something like: “illegal immigrants drive violent crime.” In our conversations, Arpaio would switch from relaxed to fiery and combative — his press conference persona — in an instant. We countered with questions of our own. It was a surprisingly candid and collegial conversation. Though Arpaio publicly raged against the press, he very much loved being covered by the media (especially on television), and he was also fond of spending time with journalists. At least when he wasn’t having them arrested. (But that’s another story.)

Arpaio was puzzled by our insistence that we review every single page of every arrest report. “Can’t we just summarize this for you?” He asked. No, not on this, I said, explaining that we were building a database of the agency’s immigration enforcement. Arpaio shrugged, “OK.”

We were puzzled, too. In moments alone, Giblin and I would turn to each other and wonder aloud, “Why are they letting us see all this?” The documents showed the operations were hugely expensive and relied on practices that seemed obviously unconstitutional. After months of more arduous reporting, we would find that the sheriff’s office had stopped investigating sex crimes, depleted its patrol division and nearly bankrupted itself in taking on immigration enforcement.

But those consequences seemed of little consequence. Arresting undocumented immigrants was the point, of course, but even more essential was press coverage of his deputies arresting undocumented immigrants.

First elected in 1992 as a tough-on-crime reformer, Arpaio built his reputation on disregard for inmates. Faced with overcrowded cells, he erected the infamous “tent city,” an outdoor jail that held the convicts in U.S. Army tents from the Korean War. During Arizona summers, temperatures sweltered well above 110 degrees in the tents. Inmates were caught stealing underwear, so Arpaio had all jail underwear dyed pink in the belief that would end the black-market for briefs. Or that’s what he told the press, which produced scores of stories about the sheriff and his endeavors.

He’d been uninterested in undocumented immigrants until 2006, when he seized on rising public anger over the issue, both locally and nationally. Once Arpaio was in the battle, he was all-in. Collateral damage accumulated quickly. By 2008, numerous U.S. citizens had been wrongly arrested by Maricopa County deputies, and several filed a federal lawsuit accusing the sheriff’s office of racial profiling.

The agency lost that case four years ago, but its remnants continue to imperil Arpaio today.

In December 2011, as the civil suit over racial profiling played out, Judge G. Murray Snow prohibited the sheriff’s office “from detaining any person based only on the knowledge or reasonable belief” that the person is in the country illegally. The direction was simple: no more local enforcement of federal immigration laws, no arrests unless deputies have evidence of a crime other than immigration.

The agency simply ignored Snow’s ruling. Over the next 18 months, deputies detained at least 171 people without criminal charges and turned them over to U.S. Immigration and Customs Enforcement, according to its own internal reports. Arpaio did not deny this occurred but pleaded ignorance, saying he was uninvolved with day-to-day operations.

In an interview with Fox News over the weekend, the former sheriff said: “I would accept the pardon because I am 100 percent not guilty.”

That’s not precisely accurate. Records of his subsequent trial show that in the months after Judge Snow’s order, Arpaio implied or explicitly said during 10 different television interviews that the agency was violating it. Further, the sheriff’s office issued six news releases saying much the same.

However, the president’s justification for an Arpaio pardon does not rest on his innocence on the charge of disregarding the courts. “Is there anyone in local law enforcement who has done more to crack down on illegal immigration than Sheriff Joe?” Trump told Fox News. “He has protected people from crimes and saved lives. He doesn’t deserve to be treated this way.”

Trump’s assertion is at odds with our reporting. In the shift to full-time immigration enforcement, Giblin and I found that the sheriff’s police work faltered across the board in its mission to protect the citizens of Maricopa County. Detectives shelved dozens of sex crime cases without investigating them. By Arpaio’s own admission, the number of uninvestigated sex crime cases eventually swelled to more than 400. Many of the victims were children.

Arpaio did apologize years later for failing to pursue suspected sex criminals. But he has remained largely defiant, and consistently on the record about his defiance. The former sheriff summed up many observers’ feelings in an interview for “The Joe Show,” a documentary on Arpaio’s tenure.

“It’s amazing what I say, and what I do, and what I get away with,” Arpaio told the filmmakers. “It’s amazing.”

Ryan Gabrielson and Paul Giblin were awarded a 2009 Pulitzer Prize for revealing how Arpaio’s “focus on immigration enforcement endangered investigation of violent crime and other aspects of public safety.”