Arizona Sheriff Joe Arpaio -- who has been at the center of controversy for his crackdown on immigrants in Maricopa County for several years -- issued an apology in court this week for ignoring a previous order to cease his immigration patrols during an investigation of the program.

Arpaio is currently in federal court facing contempt-of-court hearings connected to a racial profiling lawsuit against him for the anti-immigration patrols his department has conducted for several years.

While Arpaio, who has made headlines nationwide for his controversial stance and programs on immigration, has faced both a federal lawsuit and a lawsuit from the U.S. Department of Justice, this case stems directly from a class-action lawsuit dating back to 2007. Manuel De Jesus Ortega Melendres, a Mexican tourist, filed the lawsuit against the sheriff, his office and Maricopa county after he claimed police stopped him in a car in Cave Creek, Maricopa County and held him unlawfully for nine hours; others have since come forward with similar complaints against Arpaio's office.

In December 2011, U.S. District Judge G. Murray Snow -- who is presiding over the case -- ordered Arpaio's department to cease detaining people, specifically minorities, "based only on knowledge or reasonable belief, without more, that the person is unlawfully present within the United States."

The judge later ruled in 2013 -- nearly two years after Snow's orders to halt immigration patrols -- Arpaio and the sheriff's office had been racially profiling Latinos during traffic stops, which led to the contempt-of-court hearing this week.

In court, Arpaio gave a stunning admission under oath that his former lawyer gave the go-ahead on a secret investigation on Snow's wife. When asked by the judge is he was aware of Snow being investigated by anyone, Arpaio replied, "We weren't investigating you. We were investigating some comments that came to our attention."

The hearing could have serious ramifications for Arpaio and his department. If Snow finds that the department acted in contempt of court, a trial date will be set and Arpaio, along with his lieutenants, could face up to imprisonment if convicted.

Arpaio issued an apology to the court on the stand this week.

"I have a deep respect for the courts," he said. "It really hurts me ... after 55 years to be in this position. I want to apologize to the judge. I should have known more about these court orders that slipped through the cracks."

As the hearing goes on, Arpaio is also facing another immigration-related lawsuit stemming from a workplace raid at a restaurant in Phoenix. During that raid, according to The Arizona Republic, restaurant owner Bret Frimmel was arrested on identity theft charges, which were brought against the owner thanks to an Arizona law targeting employers who hire undocumented immigrants for work.

While the charges against Frimmel have since been dismissed after a judge ruled that investigators had no probable cause for his arrest warrants, Frimmel and one other person arrested in the raid have filed an amended lawsuit against Arpaio seeking punitive damages on the grounds of both wrongful arrest and prosecution, emotional distress and negligence.