Baltimore Police Officer William Porter, right, and his attorneys Joseph Murtha, left, and Michael Schatzow arrive at the courthouse in Baltimore for pretrial hearings on Jan. 6. (Bryan Woolston/Reuters)

Uncertainty was cast Friday over the most high-profile trial in the death of Freddie Gray just days before it is set to begin when a Maryland appeals court temporarily blocked the state’s key witness from testifying.

Baltimore prosecutors said they need Officer William G. Porter’s testimony to prove their case against Officer Caesar R. Goodson Jr., who was driving the police van in which Gray suffered a fatal neck injury. Goodson’s trial is set to begin Monday.

This week, a judge agreed that Porter — who is facing a retrial in the case — could be forced to take the stand. But the Court of Special Appeals issued a stay on that ruling after Porter’s attorneys argued that their client couldn’t testify against a fellow officer without damaging his right to a fair trial.

What will happen next is uncertain. The appeals court issued only a temporary stay and hasn’t made a final decision. Experts said the legal issue facing the appeals court and the fact that it was coming to a head on the eve of a major trial were virtually unheard of in Maryland — or elsewhere.

It’s unclear whether the legal wrangling will delay Goodson’s trial. As of Friday evening, a court representative said that prosecutors had not asked to postpone the case, although legal experts said such a motion could be forthcoming. Goodson is facing a second-degree depraved-heart murder charge, the most serious faced by any of the six officers charged in Gray’s death.

The legal drama that was unfolding has high stakes for both Porter and Goodson.

Porter’s first trial on manslaughter and other charges ended in December with a deadlocked jury. He faces a second trial in June.

In court filings submitted Friday, prosecutors said the appellate court’s intervention was unnecessary and underscored how pivotal Porter’s testimony is to their case against Goodson.

“Enjoining Porter from testifying as a State witness in Goodson’s trial . . . irreparably harms the government’s ability to prosecute Goodson for the death of Freddie Gray,” said a filing from the Maryland attorney general’s office on behalf of city prosecutors. “The State has one opportunity to try Goodson. If the State is enjoined from calling Porter as a witness at the time of Goodson’s trial, there is no remedy.”

The prosecutors also argued that state law has protections to preserve Porter’s constitutional rights if he were to testify for the state. Prosecutors said they would have a hearing before Porter’s retrial to show that all the evidence the state intends to introduce against him would be independent of his compelled testimony. If the state can’t meet that burden, the evidence would be tossed out. Prosecutors said they also intend to have him testify against Sgt. Alicia White, who faces manslaughter and other charges.

Legal experts said the issue of whether Porter should testify is novel in Maryland. Immunity is typically granted in exchange for grand jury testimony or a plea deal but rarely to a defendant the state intends to have stand trial.

Adam Ruther, a defense attorney and former Baltimore prosecutor, said it is hard to know how long it might take a three-judge panel to come to a decision, although he expected that it would work quickly. “Issuing a ruling on which there is not a prior precedent does not happen with a flick of a pen,” Ruther said. “This is pretty unusual.”

Ruther said the trial might be delayed or the judge might allow jury selection to go forward Monday if the appeals court thinks it will have enough time to make a decision before opening statements begin.

Goodson drove the police van in which Gray suffered a broken neck after he was arrested in April. Porter met the van at a handful of stops across the city. Prosecutors accuse both of failing to properly strap Gray into the van and ignoring his pleas for help, charges that both officers deny. Gray’s death, a week after his injury, ignited protests and then riots in Baltimore.

Baltimore Circuit Court Judge Barry G. Williams’s order compelling Porter to testify against Goodson was a major victory for prosecutors. At Wednesday’s hearing, Williams noted how unusual it was: “I find myself in uncharted territory,” he said before issuing the order. The judge also warned that the state’s decision to call Porter as a witness could jeopardize his retrial.

Legal experts said the state’s case against Goodson could be in doubt without Porter’s testimony. During his trial, Porter testified that he told Goodson and White that Gray needed medical care. None was sought.

“Without Porter, it would be a glaring hole there,” said Baltimore defense attorney Warren A. Brown. “Without Porter, who’s to show that Goodson knew anything about the man’s medical condition?”