MONTREAL -- The legal case around an attack on a Montreal police officer took a sharp turn on Wednesday when new surveillance video came to light, leading to the immediate release of the man accused.

The prosecution stayed all charges against Mamadi III Fara Camara, who was arrested last week on suspicion of attempted murder of an officer in Parc-Extension.

In court, the prosecution said the stays were based on "new information" and Camara, a 31-year-old PhD student at Montreal's Polytechnique engineering university, was released. 

In a highly unusual scene, the presiding judge allowed him to walk out of the courtroom by its front door rather than by the door where inmates are usually released.

As soon as Camara walked into the hallway, he was welcomed by about 15 friends and family members who had shown up for what had been originally scheduled as his bail hearing.

They applauded as he walked by, visibly in shock and without stopping to speak to media. 

One of Camara's lawyers, Joanie Chainey, told CTV News that the prosecution provided defence lawyers with surveillance footage on Wednesday morning, right as they were preparing to enter the bail hearing.

It was "a surveillance video that captured a bit what happened," she said -- it showed an area around Highway 40, which passes along the top of Parc-Extension, near where the attack happened last Thursday at 900 Cremazie Blvd. East.

The video was from one of the province's Ministry of Transportation cameras.

All the evidence against Camara had been circumstantial, Chainey said, and the video raised the question of whether "there was a problem of identification."

There was "no DNA found... I don't believe the firearm was found," she said.

"There was no direct evidence pointing to Monsieur Camara. It was all circumstantial based on the fact that he was stopped earlier for a ticket."

On top of his academic work, Camara is an Uber driver, and he had been ticketed earlier that day by the officer in question, Sanjay Vig.

Vig was later attacked just before 4 p.m., police said. They reported at the time that it occurred during a traffic stop, when a man allegedly took Vig's firearm off his belt, and Vig fled down an alleyway.

His attacker allegedly followed him and shot twice. Witnesses said they heard two gunshots. Vig suffered a head injury during the incident, though he reportedly wasn't shot and he was declared out of serious danger later that night.

At the time, the officer called for backup and a manhunt ensued.

Camara was arrested the same day. But from the evidence available about the attack, "there was no clear evidence about the identification of the suspect," Chainey said.

"There was nothing in the evidence that was clearly showing that Monsieur Camara was the real suspect."

About the video, she said she "cannot say exactly what it was showing," except to confirm that "nothing from the video was proving that Monsieur Camara did the infraction."

As the two legal teams discussed the new evidence, Camara's bail hearing was postponed from the morning to the afternoon, and then cancelled, as the prosecution decided to stay the charges around 4:00 p.m.

Police will continue investigating the case, she said. 

In a statement, the Crown prosecutors' office said that "following the progress of the investigation and the latest information provided, we believe that it is no longer possible to support at present, in the current state of affairs, the accusations against Mr. Camara."

Since the investigation is ongoing, the Crown has no further comment, said the statement. Montreal police declined to comment, as did the Montreal Police Brotherhood. 

This semester, Camara had not only been studying at Polytechnique but was also working as a laboratory assistant for a remote course, the school told CTV News.

He was suspended from his job there when he was charged and jailed last week. But after his release, he may get his job back.

"Polytechnique is aware of the withdrawal of charges and consequent release of Mamadi III Fara Camara," said a spokeswoman from the school.

"The Polytechnique community is relieved to learn of this decision, both for his sake and for that of his loved ones. Mr. Camara will be met with in order to discuss his reinstatement on campus and the recommencing of his duties. Support will be offered to him." 

Alain Babineau, a former RCMP officer who is now an adviser on racial profiling, said the case raises many questions, especially because the charges that were stayed were such grave ones.

"These are very serious charges and one would have thought the Crown would have enough evidence, at the very least, to move forward with the preliminary inquiry," he said.

"To me, it's very stunning."

--With files from CTV's Stephane Giroux