President Donald Trump is forcefully defending his decision to pardon Joe Arpaio, the controversial former Arizona sheriff who was accused of racially profiling Latinos.

“Well, a lot of people think it was the right thing to do,” Trump said during a press conference Monday when asked about his timing on the pardon, which came on a Friday afternoon in the lead-up to Hurricane Harvey. “And actually, in the middle of a hurricane, even though it was a Friday evening, I assumed the ratings would be far higher than they would be normally.”

Arpaio, a long-time Trump supporter, was found guilty of contempt of court in July for refusing to stop detaining people based on suspicions about their immigration status. He had not yet been sentenced, and faced up to six months in prison.

Trump made his comments at a White House press conference alongside Finnish President Sauli Niinistö. Trump said he believed Arpaio had been treated "unfairly" in the fall when Arpaio lost reelection in Maricopa County.

"Sheriff Joe is a patriot. Sheriff Joe loves our country," Trump said. "Sheriff Joe protected our borders, and Sheriff Joe was very unfairly treated by the Obama administration, especially right before an election — an election that he would have won, and he was elected many times. So I stand by my pardon of Sheriff Joe, and I think the people of Arizona who really know him best would agree with me."

In his justification, Trump compared his pardon of Arpaio to others made by Presidents Bill Clinton and Barack Obama of "dangerous criminals" and "drug dealers," among others.

“But I wanted to look at some of the other people that were pardoned over the years, and if you look at, as an example, President Clinton pardoned Marc Rich, who was charged with crimes going back decades,” Trump said, highlighting Clinton's controversial last-minute pardon of a financier whose ex-wife was a Democratic donor.

He added that Obama “commuted the sentence of Chelsea Manning, who leaked countless sensitive and classified documents to WikiLeaks, perhaps, and others.”

Trump seemed to suggest that by comparison, his pardon, which was immediately criticized by both Republicans and Democrats, was not as scandalous.

Arpaio and Trump both have hard stances on immigration, an area both of them found common ground on during last year's presidential campaign.

Trump has long promised a border wall along America's southern border, stating since the first day of his campaign that Mexico would pay for it. More recently, the president has suggested Congress will instead foot the bill, at least initially, and even threatened a government shutdown over funding for the wall last week.

Congress has shown no interest in shutting down the government over the wall. But Trump did not back off his threat of a shutdown on Monday, even when he was asked if the damage from the storm in Texas had changed his mind.

“I think it has nothing to do with it, really,” Trump said, promising relief funding would move quickly. "I think this is separate." He later added he hoped there wouldn't have to be a shutdown to secure funding for the wall.

"I hope that’s not necessary," he said of a shutdown. "If it’s necessary, we’ll have to see. But I hope that’s not necessary."

Mexico, meanwhile, has shown no interest in funding the wall. But asked if Mexico was still going to pay for the wall, Trump insisted the country would, and went on his now-familiar campaign riff about why he thinks the wall is necessary.

"One way or the other, Mexico's going to pay for the wall," Trump said. "It may be through reimbursement, but one way or the other, Mexico will pay for the wall."

Lissandra Villa is a politics reporter for BuzzFeed News and is based in Washington, DC.