The court said it would allow both claimants to “possess, transport and use cocaine” but not sell it, according to Mexico United Against Crime (MUCD).
MUCD, which seeks to end the country’s “war on drugs”, called the ruling a “historic step”.
The decision must be reviewed by a higher court before it is enforced.
MUCD said the Mexico City court ordered the country’s health authority, Cofepris, to authorise the two claimants’ use of cocaine.