Prosecutors in Cook County, Ill., dropped charges against Jussie Smollett on Tuesday, an astonishing reversal that came a month after the actor was arrested, charged with lying to police about a bigoted attack and pilloried by Chicago’s top police official on live television.

Prosecutors announced their decision only 18 days after a grand jury had indicted Smollett on 16 felony counts. In dropping the charges, officials cited the actor’s history of volunteer work and the two days of community service he had performed since his arrest, as well as his agreement to forfeit his $10,000 bond to the city.

Smollett — who is gay and black — first told police in January he was attacked by men shouting racial and homophobic slurs, along with invoking President Trump’s campaign slogan, “Make America Great Again.” Since then, the case has played out in full view of the public, first sparking an outpouring of support for the actor and then outrage as the police said that, rather than being a victim, Smollett was the perpetrator.

Joe Magats, the first assistant state’s attorney in Cook County, said in an interview Tuesday that such a dismissal was not uncommon and an alternative to prosecution allowable under Illinois law. The office took into account Smollett’s lack of a violent criminal background and the “facts and circumstances of the case,” Magats said. The decision “should not be considered by anyone as a statement, a signal, a hint, anything, that the case is weak or the case fell apart.”

But the prosecutor’s decision prompted stern rebukes from top officials in the city, which played out again live on television.

Police Superintendent Eddie Johnson said Smollett and his attorneys “chose to hide behind secrecy and broker a deal to circumvent the judicial system.”

Mayor Rahm Emanuel (D) said: “This is, without a doubt, a whitewash of justice and sends a clear message that if you’re in a position of influence and power, you’ll get treated one way, other people will be treated another way. There is no accountability.”

Emanuel added that the $10,000 bond “doesn’t even come close” to the resources the city used for the investigation into Smollett and his claims.

Magats insisted the decision should not be viewed as an exoneration of Smollett and said he stands by the police department. “They did an outstanding job, and we stand by the decision to charge Mr. Smollett,” said Magats, who took over the case when State’s Attorney Kim Foxx recused herself before the actor’s arrest, with her office citing conversations she had with a Smollett family member.

But the “Empire” actor spoke as if he had been vindicated. “I have been truthful and consistent on every single level since Day One,” Smollett told reporters at a Chicago courthouse. “I would not be my mother’s son if I was capable of one drop of what I was accused of. This has been an incredibly difficult time, honestly one of the worst of my entire life.”

In response to questions about Smollett’s community service, prosecutors provided a letter from the Rainbow PUSH Coalition detailing volunteer work Smollett performed on Saturday and Monday. The office also provided testimonials from two others who described his previous activism and charity work.

Prosecutors defended the decision as a fairly common practice, citing statistics from December 2016 to November 2018 showing that about 5,700 out of 60,000 cases had been referred to “some kind of deferred prosecution or alternative prosecution.”

Smollett’s attorney, Patricia Brown Holmes, offered a different characterization, telling reporters inside the courthouse Tuesday that the actor “voluntarily” forfeited his bond and that there was no deal made with prosecutors. “There is no deferred prosecution,” she said, and admonished the police not to “try their cases in the press.”

According to Richard A. Devine, who was the Cook County state’s attorney from 1996 to 2008, what played out in Chicago on Tuesday was unusual, particularly Johnson’s comment that he did not receive advance notice of the move.

“Going forward there are significant tensions between police and prosecutors, which is not a good thing,” Devine said. He added that it also created a “really volatile situation” coming in the middle of a mayoral election, which takes place April 2.

As for the sudden shift in the developments, Devine said it was possible that prosecutors found a problem with the case or that they wound up pushing it too quickly to indictment.

“It raises some fair questions,” he said. “Right now, a lot of people are very puzzled.”

The schism on display — with law enforcement officials tangling in public and a lame-duck mayor joining in — resonated in Chicago, which has struggled in recent years with gun violence and controversies surrounding a police force criticized for its treatment of civilians, particularly people of color.

Chicago’s police union, which has been critical of Foxx’s office, placed the blame squarely at Foxx’s feet and said moves like this further undermine people’s faith in the law enforcement system.

“We’re shocked by it, but not surprised,” said Martin Preib, second vice president of the Chicago Fraternal Order of Police.

Beyond Chicago, Smollett’s case captivated the nation’s attention as the investigation took several bizarre turns in public view.

Smollett was charged in February with disorderly conduct after allegedly filing a false police report. The actor told police in January that he had been attacked around 2 a.m. in Chicago’s Streeterville neighborhood by two people who yelled racist and homophobic slurs, wrapped a rope around his neck and poured an unidentified chemical substance on him. The actor said at least one of his attackers had yelled “This is MAGA country!” during the attack. Police at the time said they were investigating the incident as a possible hate-crime.

The actor received messages of support from celebrities, including several of his “Empire” colleagues, and advocacy organizations. In mid-February, the actor appeared on “Good Morning America,” telling Robin Roberts that he would “never be the man that this did not happen to.”

Days later, police announced that the trajectory of the investigation had changed. On Feb. 20, Smollett was named a suspect in the case, and he was arrested the following morning. At a subsequent media briefing, police said Smollett had fabricated the story of a brutal hate crime because he was dissatisfied with his salary on the Fox drama.

Johnson sharply criticized the actor, saying Smollett “took advantage of the pain and anger of racism to promote his career.” Residents also voiced frustrations with the police department, criticizing how it had poured resources into investigating Smollett’s claims in a city of high homicide rates.

Conservatives across the country also criticized the media as fueling a narrative that Trump supporters were prone to violence. “What about MAGA and the tens of millions of people you insulted with your racist and dangerous comments!?” Trump tweeted, tagging the actor.

Smollett has been adamant in denying wrongdoing, with his attorneys accusing investigators of presenting an “organized law enforcement spectacle that has no place in the American legal system.”

Smollett’s arrest reportedly caused tension on the Chicago set of “Empire,” which recently resumed its fifth season on Fox. The drama’s executive producers said in a statement last month that the actor’s character, R&B singer Jamal Lyon, would be removed from this season’s final two episodes “to avoid further disruption on set.”

In a statement Tuesday, Twentieth Century Fox said “Jussie Smollett has always maintained his innocence and we are gratified that all charges against him have been dismissed.”

Federal authorities are still investigating a threatening letter Smollett said was sent to him at Fox studios, according to a person familiar with the matter who asked not to be identified while discussing an ongoing inquiry.

Deanna Paul contributed to this report, which has been updated.