MONTREAL - Nearly three-dozen alleged members of the notorious Hells Angels biker gang walked out of a courthouse and into freedom Tuesday, exchanging hugs and smiling after a judge ordered their release.

The 31 accused were set free -- not over questions of guilt or innocence, but because it took too long to put them on trial.

The bombshell announcement prompted accusations that the Quebec justice system, already struggling with funding and workload issues, has tumbled into total disarray.

Quebec Superior Court Justice James Brunton said the justice system is simply unable to provide the labour needed to try the 155 alleged bikers rounded up in a massive 2009 police crackdown.

The operation, dubbed Operation SharQc, involved raids by the RCMP, and provincial and municipal police with arrests in Quebec, New Brunswick, France and the Dominican Republic.

The judge criticized the provincial justice minister and director of criminal prosecutions for simply assuming the justice system could handle such a large and complex case.

The judge said the delays would have prevented the accused from having fair trials. Defence lawyers insist it could take 10 years before the last of the accused goes to trial.

Later Tuesday, the Crown announced it would appeal the decision to release the suspects -- who account for precisely one-fifth of the accused rounded up in the 2009 raids.

Martine Berube, a spokeswoman for the director of criminal prosecutions, said if the Court of Appeal agrees the judge erred in his ruling, the charges against the 31 people freed Tuesday could be maintained.

"It's very hypothetical and it depends on the decision of the Court of Appeal," she said. "But it would put these people in the state they were in before the stay (of proceedings), so they would face the same charges."

The provincial opposition was scathing in its criticism.

"This is clearly a total failure of the criminal justice system unfolding before our eyes today and that failure is very clear," said Veronique Hivon, justice critic for the Parti Quebecois.

"There was a total failure, total improvisation and total lack of management of the SharQc mega-trial," she told a news conference at the provincial legislature.

Quebec's judicial system has been beset with problems in recent months.

The province's Crown prosecutors had to be ordered back to work after they went on strike in the spring, complaining they had a crushing workload and that they were underpaid compared to their counterparts in other provinces.

The two-week strike paralyzed the provincial justice system and prompted the resignations of several senior prosecutors.

The government promised to eventually hire more prosecutors.

Charges against the total 155 accused include murder, gangsterism, drug trafficking and conspiracy.

About 2,200 witnesses have been called and if evidence contained on four computer discs was printed out, it would stretch 145 kilometres.

The cases of 124 other accused have been divided into five mega-trials.