By a vote of six to three, the court refused to allow residents in 10 states to use the drug with a doctor’s permission and under highly regulated conditions.
The ruling means federal authorities in 10 states may arrest terminally ill patients who use the drug as well as those who provide it to them.
But some states remain defiant, saying medical certificates authorising marijuana will still be dispensed.
The majority of the judges said they were concerned that in light of the thriving illegal drug trade “no small number of unscrupulous people” were exploiting state exemptions.
In the judgement Justice John Paul Stephens wrote “the exemption for cultivation by patients and caregivers can only increase the supply of marijuana in the California market.”
But in California, where residents have been allowed to grow their own marijuana with a medical prescription since 1996, San Franscisco’s health department said it was “business as usual”.
The Associated Press reports that in all ten states affected by the ruling, users could still get a doctor’s prescription for marijuana.
Despite the Supreme Court’s decision, some state authorities have expressed reservations about arresting seriously ill people.
Montana’s attorney general Mike McGrath said users would not be prosecuted under state laws and the state had no obligation to help federal investigators follow through with arrests.
But in Colorado, US attorney’s spokesman Jeff Dorschner said state authorities would confiscate marijuana if it was found.
The two Californian women who brought the case to the Supreme Court say they will defy the ruling because smoking marijuana helps relieve their pain.
“I’m just going to keep doing what I’m doing. I don’t really have a choice but to, because if I stop using cannabis, I would die,” said mother of two Angel Raich.
Ms Raich says smoking pot every two hours gives her mobility and helps her cope with an inoperable brain tumour.
Her friend Diane Monson says she will keep growing marijuana plants to ease the pain of her degenerative spine disease.
“I’m going to have to be prepared to be arrested,” she said.
The pair began their legal battle after federal agents seized and destroyed six of Ms Monson’s cannabis plants in 2002. Local officials, however, concluded their use of marijuana under the state’s law had been lawful.
The Bush administration, which had strongly opposed state marijuana laws welcomed the court’s decision.
The US government’s head of drug control John Walters said in a statement: “For years, pro-drug groups seeking the legalisation of marijuana and other drugs have preyed on the compassion of Americans to promote their political agenda and bypass FDA’s (Food and Drug Administration) rigorous standards, which have safeguarded our medical supply for over 100 years.”
“To date, science and research have not determined that smoking a crude plant is safe or effective,” Mr Walters said.
Medical marijuana advocates are looking to Congress as a possible avenue to reverse the decision but many are doubtful Congress would allow the legal use of the drug.
California’s governor Arnold Schwarznegger said “it is now up to Congress to provide clarity for not only California, but the other states that already have laws recognising the use of marijuana for medical purposes.”