Updated

President Trump granted a pardon to Joe Arpaio, the former sheriff of Maricopa County, Ariz., on Friday.

Arpaio, 85, was recently found guilty of criminal contempt for defying a judge's order to stop traffic patrols that allegedly targeted immigrants.

He had been charged with misdemeanor contempt of court for allegedly willfully defying a judge’s order in 2011 and prolonging his patrols for another 17 months.

Arpaio acknowledged extending the patrols, but insisted it wasn't intentional, blaming one of his former attorneys for not properly explaining the importance of the court order and brushing off the conviction as a "petty crime."

He was expected to be sentenced on Oct. 5 and faced up to six months in jail if convicted.

"Sheriff Joe Arpaio is now 85 years old, and after more than 50 years of admirable service to our Nation, he is worthy candidate for a Presidential pardon," the White House said in a statement.

"I am pleased to inform you that I have just granted a full Pardon to 85 year old American patriot Sheriff Joe Arpaio," the president tweeted on Friday night. "He kept Arizona safe!"

Arpaio thanked Trump in an earlier tweet, saying that his conviction was the result of a "political witch hunt by holdovers in the Obama justice department."

Known for his controversial takes on many issues, including his "birther" campaign against former President Barack Obama and for housing inmates in desert tent camps, Arpaio is best known for his approach to battling illegal immigration. In 2009 he claimed to have arrested 30,000 illegal immigrants since starting his efforts in 2005.

At a rally in Phoenix, on Tuesday, the president asked supporters in the crowd if Arpaio was “convicted for doing his job?”

The crowd cheered.

“He should have had a jury, but I’ll make a prediction: He’ll be just fine,” Trump said. “But I won’t do it tonight, because I don’t want to cause any controversy.”

"We’ll see what happens," Arpaio said amid discussion of the pardon.

“[I]t doesn’t matter because I’m still going to support him as long as he is the president of the United States because that’s the way I am," Arpaio said. "I don’t desert for political reasons. I’ll stick with him.”

But Sen. Jeff Flake, R-Ariz., who has had a public feud with Trump in recent weeks, was unsupportive of the move.

"Regarding the Arpaio pardon," Flake wrote on Twitter. "I would have preferred that the President honor the judicial process and let it take its course."

During the presidential campaign, Arpaio showered Trump with support. Trump, meanwhile, has invoked Arpaio's name in his calls for tougher immigration enforcement and used some of the same immigration rhetoric and advocated for tactics that made the former Arizona lawman a national name a decade earlier.

Arpaio appeared for Trump at rallies in Iowa, Nevada and Arizona, including a huge gathering in the affluent Phoenix suburb where the sheriff lives. Arpaio also gave a speech at the Republican National Convention in which he said Trump would prevent immigrants from sneaking into the country.

The Associated Press contributed to this report.