The hearing took place before the Supreme Court of Canada on Tuesday, with the ruling coming directly from the bench.
The Crown was trying to have a ruling by Quebec Superior Court Justice James Brunton overturned.
He ordered the stay of proceedings for 31 men in 2011. They had been arrested as part of the 2009 police sweep dubbed SharQc and were charged with various drug-related offences and in some cases, gangsterism.
The Supreme Court ruled that Brunton did not err in exercising his discretion to order a stay in the case, requested by the defence lawyers.
The court agreed that defendants would be prejudiced by the lengthy delays and a trial would not occur within prescribed time limits as required by Canada's Charter of Rights and Freedoms.
"The Crown didn't have any realistic plan on how to proceed with these charges in a reasonable delay," Chief Justice Beverley McLachlin said in French. "The unique character of these extraordinary circumstances convinces us that the approach taken by Justice Brunton was the right one."
Defence lawyer Louis Belleau said the drug case against the 31 is now over.
"It's finished," Belleau said.
The criminal attorney said he doesn't think this particular case sends a message that mega-trials are unmanageable. Belleau said the Crown simply didn't manage this case properly.
The Crown went to the Supreme Court after losing an appeal in Quebec's highest court in April of last year.
The police sweep led to the arrest of more than 150 people, with two mega-trials expected later this year for the remaining 51 accused.
It was decided in September that the remaining accused will be tried in two groups. They face a wide range of charges that include gangsterism and murder.