Justice Donald Taliano found that sick people cannot get access to medical marijuana through appropriate means and must resort to illegal actions.
He says that brands ill people who should be able to get the drugs as criminals.
The St. Catharines justice declared the program to be invalid, as well as the laws prohibiting possession and production of cannabis.
But he suspended his ruling for three months, giving Ottawa until July to fix the program or face the prospect of effectively legalizing possession and production of cannabis.
The government is expected to appeal the ruling, which could push back the three-month stipulation and effectively leave the current system in place.