A Dutch court on Friday upheld a new law that will prevent foreign visitors from buying marijuana in coffee shops across the Netherlands, potentially ending the decades of “pot tourism” for which this city and others became universally known.

A group of coffee shops had challenged the government plan, launched after southern cities in the Netherlands complained of increased levels of drug-related crime. The decision means that coffee shops in the south must stop selling cannabis to foreign tourists by May 1, while Dutch and foreign residents will be eligible for a “weed pass” that allows them to purchase it legally. The plan is to be rolled out to other Dutch cities, including the popular tourist center of Amsterdam, by next year. The ban does not extend to carrying or consuming marijuana.

The Netherlands is moving toward tightening its renowned liberal policy on the sale of marijuana even as other countries, including the United States, are engaging in increasingly heated debates over the legalization of “soft drugs.”

Attorneys for the Netherlands’ cannabis cafes — which number more than 600 nationwide — had argued in the Hague district court that prohibiting visitors from buying marijuana while allowing Dutch citizens and residents to do so is illegal under national anti-discrimination laws. They vowed on Friday to appeal the case.

“This is a bad decision, not only for the foreigners who can be discriminated against now, but also for the image of the Netherlands in other countries,” said Maurice Veldman, attorney for a group of cafes that challenged the new law. “We are not a free country anymore because our government asks us to discriminate.”

A Dutch judge on Friday has upheld the government's plan to introduce a "weed pass" to prevent foreigners from buying marijuana in coffee shops. (Peter Dejong/AP)

The court ruled that the new law is legal because of the rise in criminality linked to the Dutch drug trade. But the decision is fiercely opposed by city officials in Amsterdam, where the cannabis cafes are a major tourism draw and where myriad coffee-shop owners have vowed to ignore the law once it comes into effect.

Among the slanted Dutch houses of Amsterdam’s infamous red light district, Michael Veling, 56, owner of the 420 Cafe, said he was outraged by the ruling. Veling, who is also chairman of the Dutch Union of Cannabis Retailers, said coffee shop owners in the city of Maastricht, where the law comes into effect next week, were preparing to disobey “this ridiculous law” and were “ready to be arrested.”

“This is not good for Amsterdam, because we are not prone to the kind of criminal activities around coffee shops that are going on in the south of Holland,” said Veling, whose cafe offers an extensive menu of legal marijuana.

“We have tourists that just want to have a smoke,” he added. “If they’re not going to get it, they will ask Dutch people who actually have a pass for the coffee shop to buy it. Or they will fall into the hands of the illegal street sellers.”

Special correspondent Marit Van Kooij contributed to this report.