The Supreme Court found that adults have a "fundamental right to the free development of the personality" without interference from the state.
"That right is not absolute, and the consumption of certain substances may be regulated, but the effects provoked by marijuana do not justify an absolute prohibition of its consumption," the ruling read.
The court ordered officials to allow the complainants to use cannabis, though they were banned from selling it or using any other drugs.
The two cases followed three similar rulings between 2015 and 2017, meaning the judgement now applies more widely – under Mexican law five similar decisions on a particular issue sets a precedent.
"With the existence of five precedents in the same vein on the subject, the judgment will be mandatory for all courts in the country," the high tribunal said.
The rulings do not technically make cannabis legal in Mexico, as the country’s legislature did not change any law. However, it does establish that any cases brought before a court should rule in favour of allowing recreational use.
Mexico United Against Crime (MUAC), a group opposing conservative drugs policies, hailed the rulings as opening “the door to regulation of cannabis”.
“Mexico must move toward the regulation of drugs to improve conditions of justice and peace in the country,” it added.
"The Supreme Court has done its job ... The responsibility for issuing the corresponding regulation falls on congress," Lisa Sanchez, MUAC’s director general, said in a statement.
Steve Rolles, senior policy analyst for the Transform Drug Policy Foundation, said the court ruling should spur the UK government into ending the "ruinous war on drugs".
“Today's legalisation of cannabis in Mexico means you can now travel the entire West Coast of North America, from the Arctic circle in Canada, to the Mexican border with Guatemala, without leaving a legal cannabis jurisdiction," he said.
“We congratulate our Mexican colleagues on a truly historic victory that can only serve to accelerate the much needed reforms in Mexico, the Americas and indeed globally, as well as creating space for debate on the legalisation and regulation of other drugs.
“It’s time for governments, including in the UK, to acknowledge the fundamental failures of prohibition and the injustices of criminalising people who use drugs. They must follow the leadership being shown in Mexico and around the world, and bring an end to the ruinous war on drugs."
Join our new commenting forum
Join thought-provoking conversations, follow other Independent readers and see their replies