President Donald Trump has issued a pardon for Joe Arpaio, the controversial former Arizona sheriff who was convicted of criminal contempt.
Arpaio, who styled himself as "America's toughest sheriff", was found guilty of violating a 2011 order to stop detaining migrants.
Mr Trump's announcement came during a campaign rally in Phoenix, where he was also greeted by dozens of protesters.
Arpaio frequently appeared on the campaign trail with Mr Trump in 2016.
He was among the earliest supporters of Mr Trump, who branded himself "the law-and-order candidate" before he was elected.
Arpaio, 85, rose to national prominence for his sweeps of undocumented immigrants in Hispanic communities, and for detaining Spanish-speakers under suspicion of being undocumented migrants.
The Republican ex-lawman was convicted in July of deliberately violating a 2011 injunction halting his practice of detaining migrants who are not suspected of having committed a state crime. Only federal officers have jurisdiction over immigration.
Arpaio could have faced six months in jail and was set to be sentenced in October.
Arpaio was born in Springfield, Massachusetts, and served in the US military before he became a police officer.
He was first elected as sheriff of Maricopa County in 1993 and was subsequently re-elected five times before he lost in November 2016.
Maricopa County includes Phoenix, a population of more than four million people, about 30% of whom are Latino.
He first made headlines in 1993 for the construction of Tent City, an open-air jail created for undocumented immigrants that he billed as a "tough on crime" solution to overcrowded prisons.
Arpaio famously forced the prisoners to wear pink underwear and socks and old-fashioned black-and-white striped prison jumpsuits. The inmates lived outdoors while enduring sweltering Arizona desert temperatures.
He also revived chain gangs, including a voluntary one for female prisoners.
Newly elected Sheriff Paul Penzone, the Democrat who defeated Arpaio, announced in April the city would close the outdoor prison.
A group of Latinos filed a class-action lawsuit against Arpaio in 2007, alleging his officers relied on race when choosing whom to stop.
US District Court Judge Murray Snow in 2011 issued a temporary injunction against Arpaio, banning him from detaining people based on their immigration status.
The order was made permanent in 2013, when Judge Snow ruled that Arpaio's office improperly targeted Hispanics in routine patrol stops for undocumented immigrants.
The case led to a federal investigation and the US Justice Department eventually sued him, accusing his office of multiple civil liberties violations, including punishing Hispanic jail inmates for speaking Spanish.
He has described the Justice Department's investigation into his practices a "witch hunt". The case was settled in 2015.
Early Trump supporter
Arpaio, along with Mr Trump, was one of the leading figures of the birtherism movement, which questioned the authenticity of former President Barack Obama's birth certificate.
Mr Trump encouraged Arpaio in 2012, when the then-sheriff created a "cold case posse" to pursue the claim about Mr Obama's citizenship.
Arpaio re-emerged on the national stage again in 2015 as one Mr Trump's staunchest supporters during the early months of the Republican primary presidential campaign.
Mr Trump echoed Arpaio's anti-immigrant rhetoric, bolstering the ex-lawman's views on immigration crackdowns and reform.
He was a fixture at Trump campaign rallies and was given a speaking slot at the Republican National Convention.
Mr Trump returned the favour by campaigning for Arpaio, but he lost a bid for his seventh term in November 2016.
Before Tuesday's rally, Mr Trump had said he was "seriously considering" pardoning Arpaio.
"He has done a lot in the fight against illegal immigration," Mr Trump told Fox News earlier this month.
"He's a great American patriot and I hate to see what has happened to him."