In a rare move, a Cook County judge has ordered Mayor Rahm Emanuel to sit for a sworn deposition in lawsuits stemming from the controversial police shooting of a baseball bat-clutching teen and an innocent bystander.

Lawyers for the city had waged a sustained battle to prevent Emanuel or police Superintendent Eddie Johnson from having to give statements under oath, but Cook County Circuit Judge James O’Hara ordered Wednesday that both must give depositions in the coming weeks.

The ruling comes more than two months after the city’s police oversight agency determined that Officer Robert Rialmo unjustifiably shot and killed Quintonio LeGrier, 19, and his 55-year-old neighbor, Bettie Jones, while responding to a domestic disturbance on the West Side in 2015. Johnson has yet to determine whether he will adopt the disciplinary agency’s recommendation and seek Rialmo’s firing by the police board, and volumes of litigation over the shooting are still pending.

After O’Hara’s ruling, the city’s lawyers asked that the judge set a time limit for the mayor’s testimony, but he declined to do so. O’Hara said he would supervise the deposition and make sure it remained “reasonable.”

The judge set a hearing for Tuesday for the lawyers to discuss a date for Emanuel’s deposition, though the judge said the mayor must testify within the next 30 days. Johnson’s deposition is scheduled for March 15.

An attorney for the city’s Law Department, Naomi Avendano, said in court that her office might appeal the order.

Discussion at prior hearings has focused on whether Emanuel’s potential deposition would be limited to specific topics, but the judge did not address that issue Wednesday.

The city’s lawyers declined to comment as they left the Daley Center courtroom, and spokesmen for the Law Department and mayor’s office also declined to comment.

Lawyers for the LeGrier and Jones families said they want to ask Emanuel about topics such as use-of-force policies and the oft-discussed “code of silence” among officers.

Attorney Basileios Foutris, who represents the LeGrier estate, said the judge made “the right call.”

Emanuel and Johnson are “no different from anyone else before the law,” he said.

Having a sitting mayor submit to sworn testimony in a lawsuit alleging wrongdoing by the city is unusual but not unprecedented. In some cases, the possibility that a current or past mayor will have to testify has been foreclosed by a settlement.

In 2016, Emanuel, on a judge’s orders,gavea deposition in a lawsuit in which eight Chicago police officers alleged they were dumped from the mayor's security detail for political reasons after he took office. Under oath at the legal offices at City Hall, the mayor mostly responded to questions by saying he couldn’t remember details. A jury later found in favor of the city and awarded no damages to the officers.

A year earlier, city attorneys fought vehemently to prevent Emanuel from having to testify in a police whistleblower case alleging two officers were blackballed by the department for helping the FBI investigate a corrupt sergeant. The judge in that case ruled that the mayor could be subpoenaed to take the stand in light of the fact he’d acknowledged the code of silence existed. The city, however, settled the case for $2 million on the day the trial was set to begin.

In at least three lawsuits involving allegations of police misconduct litigated before and after he left office, former Mayor Richard M. Daley appeared to be on track to testify before the cases were settled.

It is also rare for police superintendents to testify in lawsuits, though it has happened occasionally in recent decades.

Rialmo's shooting of Jones and LeGrier has been a source of repeated controversy since it unfolded on the West Side the day after Christmas 2015.

About 4:30 a.m., Rialmo and his partner responded to 911 calls about a disturbance at the apartment in the 4700 block of West Erie Street where LeGrier was staying with his father. LeGrier, apparently plagued by mental health problems, had behaved erratically as a student at Northern Illinois University and had altercations with peers and run-ins with police, records show.

Jones, who lived downstairs, answered the door and pointed police to the second floor. LeGrier then came down the stairs with a baseball bat, according to an analysis released a year ago by State's Attorney Kim Foxx's office, which declined to bring criminal charges against Rialmo.

As Rialmo backed down the stairs, he fired eight times, hitting LeGrier six times, according to prosecutors. Jones, who stood behind the teen during the incident, was shot once in the chest, prosecutors wrote.

Rialmo’s attorney, Joel Brodsky, has said his client was justified in firing in self-defense.

But the December ruling from the city’s police disciplinary agency, the Civilian Office of Police Accountability, casts doubt on Rialmo’s account of events and turns in part on investigators’ determination that the evidence indicated that LeGrier did not swing the bat at Rialmo, as the officer has said.

Investigators also found that the evidence — including shell casings, witness statements and forensic analysis — suggested Rialmo was farther away from LeGrier when he fired than the officer has said.

The agency concluded that a “reasonable officer” would not have believed he was in danger of death or serious injury.

Some of the city’s lawyers’ legal maneuversin the case have also proved controversial.

Late last year, the city’s lawyers filed a lawsuit that sought to shift blame and some financial liability for Jones’ death from the city onto LeGrier’s estate. After the Tribune reported on the lawsuit a few hours after it was filed, the city’s lawyers quickly dropped the suit. Emanuel apologized, saying he did not know of the litigation beforehand but found it “callous.”

A motion Foutris filed last week argued that private lawyers representing the city displayed "contemptible behavior" during depositions. During a deposition on Feb. 14, Barrett Boudreaux, a private lawyer representing the city, asked LeGrier's mother, Janet Cooksey, "how was it that Quintonio was conceived" with his father, Antonio LeGrier, according to a partial transcript. Court records show that Boudreaux then asked, "So Antonio approached you about a sexual relationship in exchange for money; is that correct?"

Cooksey and Foutris have said that any allegation of prostitution was both baseless and irrelevant. After the Tribune inquired about Boudreaux’s questions, Corporation Counsel Edward Siskel issued a statement saying his office was reviewing the matter and would “not hesitate to take action” if the inquiry found anyone acted improperly.

In court Wednesday, the judge gave the city’s lawyers several weeks to respond to Foutris’ allegations.

After the hearing, Foutris said he’d like to ask Emanuel about the aggressive legal gambits the city’s lawyers have pursued even as the mayor has taken a conciliatory tone on the case.

“There’s a cognitive dissonance,” Foutris said.

Rialmo’s legal troubles extend beyond the lawsuits. He was charged in January with two counts of battery and one count of theft, all misdemeanors, following an early morning bar fight late last year at Moretti's Ristorante & Pizzeria on the Far Northwest Side. He is also accused of stealing the jacket of one of the men he is charged with hitting.

Brodsky has said Rialmo was defending himself against drunken aggressors and did not steal the jacket.