ALBANY — New York’s top court on Thursday dismissed an indictment against a man who spent six years jailed at Rikers Island without a trial, saying prosecutors violated his constitutional right to a speedy trial.

Reginald Wiggins was 16 years old when he was indicted on a charge of allegedly shooting and killing a teen rival at a Manhattan party in 2008.

He sat in the New York City jail, without bail, while the Manhattan District Attorney’s Office tried to get a co-defendant to testify against him. There were three mistrials and 40 adjournments in the co-defendant’s case.

In 2014, with the co-defendant’s fourth trial pending, Wiggins agreed to plead guilty to manslaughter.

But the state Court of Appeals, in a 4-3 decision Thursday, effectively wiped out the plea deal by dismissing the indictment against Wiggins, saying prosecutors “cannot justify this extraordinary delay.”

Wiggins’ lawyers say they will seek his release from Green Haven Correctional Facility, a state prison near Poughkeepsie, where he has been held since pleading guilty.

“The way we see it, a 16-year-old boy was kept at Rikers Island for six years with no opportunity for a trial,” said Ben Schatz, who argued Wiggins’ case before the Court of Appeals. “So we see this outcome as the correct result, not only from a constitutional sense but from a sense of justice. There’s only so much time you can keep a kid at Rikers Island and he says, ‘Enough. I’ll take a plea.’”

Justin Henry, a spokesman for Manhattan District Attorney Cyrus Vance Jr., said in an email: “We respectfully disagree with the majority’s opinion in this case of the murder of an innocent 15-year-old boy, and agree with the dissenting judges that this prosecution accorded with constitutional mandates. As in most cases, adjournments in this matter were requested by both parties, and additional adjournments were occasioned by circumstances beyond the parties’ control.”

The court said pursuit of the co-defendant, Jamal Armstead, couldn’t justify this “extraordinary delay.”

Prosecutors, “do not have unfettered discretion to indefinitely pursue evidence that would strengthen their case while the defendant’s trial is postponed,” Judge Eugene M. Fahey wrote for the majority.

Fahey said prosecutors pursued “Armstead’s testimony for several years, without any guarantee that they would secure it, instead of moving [Wiggins’] case to trial.”

According to court documents, Wiggins and Armstead confronted another teenage boy at the party over an alleged insult of a girl. Prosecutors said Armstead displayed a gun and pulled the trigger twice — but it never fired. Wiggins then grabbed the weapon and fired — but missed the target and instead killed a 15-year-old male bystander, prosecutors said.

Gov. Andrew M. Cuomo recently proposed changes to the state’s laws on bail and rights to a speedy trial.

Cuomo, a Democrat, proposed that defendants must consent to a speedy trial waiver signed by a judge to ensure they aren’t held for an unnecessarily long period when prosecutors fail to meet deadlines. Some lawyers have questioned whether the proposal would actually hurt defendants, because it would put the onus on them rather than lawyers and judges to move the case along.

Separately, Rikers Island, already under scrutiny for corruption, violence and poor management, would be closed by 2027 under a deal reached by New York Mayor Bill de Blasio and the City Council. Cuomo has criticized the timeline, saying it isn’t fast enough.