Alleged gang leader Nick Chan has been freed again after facing murder charges, this time because a Calgary judge issued a stay because the trial did not take place within a reasonable time.

It is the third time in two years that the 40-year-old Calgarian has beaten organized crime-related charges.

Chan, who had been in custody since his arrest in July 2013, was released on bail on Monday after the judge ruled the prosecution's star witness would not be allowed to testify.

Crown prosecutors then asked for a directed verdict but, in a surprise move on Tuesday, Justice Paul Jeffrey stayed on all charges, based on the Supreme Court's Jordan decision and Chan's right to be tried within a reasonable time.

A publication ban was in effect until after the jury was excused on Tuesday.

Chan is now free, with no conditions on his release.

"Mr. Chan is grateful for the fairness the court has shown to him throughout these proceedings," said his lawyer, Andrea Serink.

"It is very difficult to be accused of such serious crimes and have to defend yourself when you are held as a pretrial inmate, especially at the Calgary Remand Centre."

Nick Chan leaves court a free man after 5 years awaiting trials on charges of murder, weapons offences, instructing a criminal organization <a href="https://t.co/uajg1FUedC">pic.twitter.com/uajg1FUedC</a> —@CBCMeg

Prosecutors Steven Johnston and Ryan Persad have not said if they will seek an appeal.

"We did not know that this ruling was going to be coming this morning, so we were somewhat surprised," said Johnston.

"Until we have reasons, we're in a bit of a vacuum for our decision-making process."

The witness who could not testify was granted partial immunity in exchange for evidence. The witness's identity is protected by a publication ban.

Bloody gang war

Chan, said to be the leader of the Fresh Off the Boat (FOB) gang, was charged with first-degree murder for allegedly being behind the death of Kevin Anaya, who was linked to the rival Fresh off the Boat Killers (FK).

According to testimony at previous trials, Chan would pay FOB members up to $10,000 for successful hits on FK gangsters during the city's bloody 2002-09 gang war, during which 25 people were killed.

A massive police investigation dubbed Operation Desino ended in July 2013 with multiple suspects, including Chan, facing numerous murder charges.

Several were granted immunity or partial immunity deals in exchange for their testimony.

In March 2016, a jury found Chan not guilty of first-degree murder for a triple killing at Calgary's Bolsa Restaurant in 2009. In December, he was acquitted of several weapons-related charges following a trial.

The Calgary police withheld comment on Tuesday's development, pending arrival of the judge's written decision.

Chan had also faced a charge of conspiracy to commit murder and of directing a criminal organization.