For two months, the story of what happened to “Empire” actor Jussie Smollett on a frigid January night in downtown Chicago has transfixed the nation with its many plot twists.

On Tuesday, the script was flipped yet again — and in many ways it only added to the mystery.

In a stunning reversal, Cook County prosecutors abruptly dropped all charges in an indictment accusing Smollett of staging the Jan. 29 attack in Streeterville and falsely claiming he was the victim of a hate crime.

In exchange, prosecutors said, Smollett agreed to forfeit the $10,000 he’d posted for his bond and perform community service. The purported deal appeared to be hastily arranged — Smollett only completed the community service Monday — and apparently was not put in writing.

While prosecutors claimed to have overwhelming evidence, the deal did not require Smollett to admit he did anything wrong. What’s more, Smollett’s lawyers have vehemently disputed there was an agreement at all, and now the entire court file has been sealed at the defense’s request.

The unanswered questions surrounding the development left many wondering what might have happened behind the scenes. It also appeared to have caught Chicago police brass by surprise and brought swift condemnation from Mayor Rahm Emanuel, who called it a “whitewash of justice.”

“From top to bottom, this is not on the level,” Emanuel told reporters at an afternoon news conference, emphasizing repeatedly that a grand jury had chosen to bring 16 counts of disorderly conduct against Smollett. “Where’s the accountability in the system?”

Read the Chicago police investigative file on the Jussie Smollett case »

The arrangement came to light as Smollett appeared unexpectedly Tuesday morning for a previously unscheduled hearing at the Leighton Criminal Court Building. Wearing a blue wool coat, Smollett stood silently in Circuit Judge Steven Watkins’ small, third-floor courtroom as prosecutors announced they were dropping all charges. At the request of the actor’s attorneys, the judge agreed to seal the entire court record, a move that prosecutors did not oppose.

The proceedings were over within minutes. Afterward, the state’s attorney’s office issued a one-sentence statement that attempted to explain the about-face but instead only added to the confusion.

Smollett’s lawyers, meanwhile, professed the actor’s innocence, accusing police of trying the case in the media and insinuating that the two brothers who alleged that Smollett hired them to carry out the attack were the ones who should have been charged in the first place.

Before departing the courthouse, Smollett, 36, thanked his attorneys, family, friends and Chicago for supporting him through what he called “an incredibly difficult time for me.” He also thanked “the state of Illinois” for “attempting to do what’s right.”

“I have been truthful and consistent from day one,” said Smollett, wearing sunglasses and reading from notes as his hands shook.

In a telephone interview Tuesday afternoon, First Assistant State's Attorney Joseph Magats, who took charge of the case after State’s Attorney Kim Foxx stepped aside because of a conflict of interest, emphatically denied that the move to drop the charges against Smollett was a signal of any weakness with the evidence.

Magats said the office reached an unwritten deal with the defense in recent weeks to drop the charges if Smollett forfeited the $10,000 bond and did community service — an arrangement he characterized as a routine way to resolve nonviolent charges against first-time offenders.

"The bottom line is we stand behind the investigation, we stand behind the decision to charge him,” Magats, a career prosecutor who’s been with the office for nearly three decades, told the Tribune. “The fact that (Smollett) feels that we have exonerated him, we have not. I can’t make it any clearer than that."

The state’s attorney’s office later released a letter from the Rainbow/PUSH Coalition that said Smollett had performed community service — but just for two days, on Saturday and Monday.

The letter said Smollett spent several hours in their store managing sales and later gave suggestions to staff. He also took questions from students about the music and film industries.

Later, though, a spokesman for Rainbow/PUSH, which was founded on the South Side by the Rev. Jesse Jackson, said the civil rights organization was unaware that Smollett’s assistance had any connection to his court case.

"He was just a volunteer, " Don Terry said.

How Lori Lightfoot, Toni Preckwinkle reacted to Jussie Smollett's case dismissal in debate »

Smollett’s attorney, Patricia Brown Holmes, denied any deal had been made with prosecutors, contrary to Magats’ account.

The state’s attorney’s office simply dropped the charges, according to Holmes. Smollett agreed to forfeit his bond “so he could go on with his life and get this over with,” she said.

Smollett had posted 10 percent of the bond — $10,000. Ordinarily, that money would be returned to him or his attorneys, but instead it will be handed over to the city of Chicago.

In a telephone interview, Eric Sussman, Magat’s predecessor as Foxx’s top aide, said the abrupt, secretive nature of the deal “raises questions as to whether there is embarrassing information the state’s attorney’s office doesn’t want the public to know.”

“I’ve never, ever seen anything like this,” Sussman, now in private practice, said of the decision to drop charges so soon after Smollett’s indictment earlier this month.

Magats denied, however, that the dropping of the charges either signaled weak evidence or a desire for secrecy.

“It’s a mistake and it’s wrong to read into the decision that there was something wrong or that we learned something about the case that we didn’t already know,” Magats told the Tribune.