In overturning the lower court ruling, the Court of Appeal ruled the trial judge had made numerous errors in striking down the country's medical pot laws.
Among other things, the Appeal Court found the judge was wrong to interpret an earlier ruling as creating a constitutional right to use medical marijuana.
"Given that marijuana can medically benefit some individuals, a blanket criminal prohibition on its use is unconstitutional," the Appeal Court said.
"(However), this court did not hold that serious illness gives rise to an automatic right to use marijuana."
Currently, doctors are allowed to exempt patients from the ban on marijuana, but many physicians have refused to prescribe the drug on the grounds its benefits are not scientifically proven.
The Canadian HIV/AIDS Legal Network called the decision a disappointing missed opportunity.
"Allowing the current regulations to stand unchanged will leave many people with serious health conditions without effective access to legal authorization to use cannabis as medicine," said Richard Elliott, executive director of the network.
"People shouldn't have to risk going to prison in order to get the medicine they need."
The ruling comes in the case of Matthew Mernagh, 37, of St. Catharines, Ont., who suffers from fibromyalgia, scoliosis, seizures and depression.
While he argues marijuana is the most effective treatment of his pain, he said he was unable to find a doctor to support his application for a medical marijuana licence.
Mernagh resorted to growing his own and was charged with producing the drug in April 2008.
In April 2011, Ontario Superior Court Justice Donald Taliano found that sick people cannot get access to medical marijuana through appropriate means. He said that forced ill people who should be able to get the drugs to resort to criminal acts.
Taliano struck down the laws prohibiting possession and production of cannabis as unconstitutional but the ruling was put on hold pending the federal government's appeal, which was heard last May.
The Appeal Court found Taliano had relied on "anecdotal evidence" and drew unfounded conclusions that the medicinal pot scheme made it almost impossible for patients to get legal access to the drug.
"The trial judge found that the 'vast majority' of those who needed medical marijuana were unable to get physicians to sign (exemption) declarations," the Appeal Court said.
"The record does not support the trial judge's inference that they failed to obtain medical declarations only because Canadian physicians are boycotting the (medicinal pot scheme)."
Osgoode Law Prof. Alan Young said the Appeal Court decision should not be seen as an endorsement of the medical marijuana program.
"They simply didn't feel the evidence was sufficient," Young said. "The case is important to show people that the program is still failing."
He noted the court started off in its judgment by noting this was the third time the Appeal Court was reviewing the medicinal pot scheme and the government was already making changes.
In December, Health Minister Leona Aglukkaq announced Ottawa would no longer grant medical marijuana licences to users, and only doctors would be able to prescribe pot.
In Friday's decision, the court said Mernagh had failed to provide evidence from a doctor that he met the criteria for a medical exemption to the country's pot ban.
"It was not open to the trial judge to hold that Mr. Mernagh and the patient witnesses who had not obtained medical declarations were entitled to exemptions," the Appeal Court said.
Note to readers: This is a corrected story. An earlier version said the top court struck down the country's laws related to medicinal pot.
Also on HuffPost