Medical marijuana is legal in some US states and has been growing in popularity in some countries.
The court’s decision comes after an argument in which Justice Antonin Scalia said states must permit medical marijuana if it is being used for a legitimate medical purpose.
The case was brought by three people who say they have cancer, but they are not able to get access to the drug because of federal laws.
States have the authority to allow or deny medical marijuana.
“The court finds that the state of Washington has an interest in ensuring that the availability of medical marijuana is protected by the Controlled Substances Act and the laws of the state,” the court said in a statement.
The ruling is a significant victory for medical marijuana advocates who argued in the court’s 2016 decision that the Drug Enforcement Agency (DEA) had overstepped its bounds.
The Supreme Court had previously blocked states from setting their own marijuana laws, saying that they are under federal control and can’t make laws to make their own laws.