PARIS — The Dutch government’s plan to prohibit the purchase of marijuana by nonresidents cleared an important hurdle on Friday, when a court in The Hague dismissed a lawsuit brought by shop owners challenging the plan on the grounds that it was discriminatory.

The court agreed with the government that the prohibition was justified because of crime associated with people who travel to the Netherlands to buy marijuana and hashish, a resin derived from the cannabis plant. Although illegal in the Netherlands, soft drugs are tolerated. Licensed shops, called coffee shops, have been allowed to sell them since 1997, and Dutch citizens may grow up to five marijuana plants for personal use without fear of prosecution.

The center-right government of Prime Minister Mark Rutte, which took office in 2010, is seeking to tighten controls on the shops with what is known as a “weed pass” system, under which each shop would be limited to 2,000 customers and required to maintain a register of clients; the sale of drugs to nonresidents would be illegal.

Friday’s ruling cleared the way for the system to go into effect on Tuesday in the provinces bordering Germany and Belgium in the south, the areas most widely identified with drug-tourism crime. The rest of the country is to follow suit next Jan. 1.