CHICAGO (AP) — A judge decided to appoint a special prosecutor Friday to investigate the decision by Cook County prosecutors to dismiss all charges against actor Jussie Smollett, who was accused of lying to the police by claiming he was the victim of a racist and homophobic attack in downtown Chicago in January.

In a ruling that leaves open the possibility that Smollett could be charged again, Cook County Judge Michael Toomin suggested that the county's state's attorney, Kim Foxx, mishandled the Smollett case by appointing a top aide to oversee it after she recused herself.

Foxx had been in contact with a relative of the actor and had been approached by former first lady Michelle Obama's one-time chief of staff on behalf of Smollett's family, and she explained at the time that she was recusing herself to avoid "even the perception of a conflict" of interest.

In his ruling, Toomin said he had no problem with Foxx's February recusal, but that it should have included a request for a special prosecutor to take over the case. He said she had no right to hand it off to someone from her office, which he said amounted to naming her own special prosecutor.

"State's attorneys are clearly not meant to have unbridled authority to appoint special prosecutors," he said. "She appointed (her top assistant) to an office, to an entity, that has no legal existence. There isn't an office of the 'acting state's attorney.' It existed only ... in the imagination of Ms. Foxx."

"The unprecedented irregularities identified in this case warrant the appointment of independent counsel to restore the public's confidence in the integrity of our criminal justice system," the judge said.

Toomin also left open the possibility that the special prosecutor could charge Smollett again — either with the original charges accusing him of lying to police or with other counts.

The Chicago Police Department, which has never disguised its anger over the decision to drop the charges, vowed to assist the special prosecutor.

"We stand firmly behind the work of detectives in investigating the fabricated incident reported by Jussie Smollett & #ChicagoPolice will fully cooperate with the court appointed special prosecutor," department spokesman Anthony Guglielmi tweeted.

In a written statement, Foxx took issue with the ruling and explained that she "followed the advice of counsel and my then Chief Ethics Officer" to recuse herself.

Smollett's attorneys did not immediately respond to a request for comment.

Foxx has been under fire for her handling the investigation, including from the Chicago Police Department and the former mayor. Her office charged Smollett with 16 counts of disorderly conduct after police concluded that Smollett had staged the early-morning Jan. 29 attack on himself and had paid two acquaintances to help him pull it off. But it stunningly dropped all of the charges weeks later, prompting an outcry from police and leading a former state appellate judge, Sheila O'Brien, to call for a special prosecutor.

In filing a petition requesting a special prosecutor, O'Brien said it appeared to her and others that Smollett had "received special treatment" from Foxx's office.

Foxx has defended her handling of the case and said Smollett was treated no differently than thousands of other defendants in low-level cases whose charges have been similarly dropped since she took office. And Foxx, who has publicly wondered if her being black has anything to do with the criticism she has received, said she would welcome an independent investigation. But her office opposed such a special prosecutor, explaining that the investigation would just duplicate the efforts of a county inspector general's office probe that is already underway.

Toomin is now required by law to ask the state's attorney general's office or the state appellate prosecutor to serve as special prosecutor. If they decline, he must make the same request to elected state's attorneys throughout Illinois. That is what happened in the case of former Chicago police officer Jason Van Dyke, who was charged with murder in the 2014 shooting death of a black teenager, Laquan McDonald. The case was ultimately prosecuted by Kane County State's Attorney Joseph McMahon after Foxx's predecessor, Anita Alvarez, recused her office. McMahon won a second-degree murder conviction against Van Dyke.