JEFFERSON CITY, Mo. — Electric car maker Tesla Motors cannot bypass dealerships and sell vehicles directly to Missouri customers, a judge ruled Wednesday in another setback to the company’s efforts to cut the middleman out of its deals.

Cole County Judge Daniel Green ruled that the Missouri Revenue Department violated state law when it gave the California-based manufacturer a license for a University City dealership in 2013 and a franchise dealer license for a Kansas City dealership in 2014. That allowed the automaker to sell cars directly to customers instead of through a dealership serving as a middleman.

The Missouri Automobile Dealers Association sued the department, arguing that it had given Tesla special privileges, since other manufacturers typically provide cars to franchised dealerships to sell.

Green did not rule on the association’s claims that the revenue department’s actions were unconstitutional, but agreed that “a single entity may not manufacture vehicles for sale in Missouri and possess a Missouri new motor vehicle dealer license.”

A spokeswoman for the attorney general’s office, which represented the revenue department, said it’s reviewing the ruling.

Tesla had argued the lawsuit was an attempt to decrease competition and limit consumer choice in Missouri.

Will Nicholas, a Tesla spokesman, said the company disagrees with the ruling and will appeal it.

“Tesla will take all appropriate steps in the courts to ensure that Missouri consumers continue to have the right to choose how they purchase their vehicles,” he wrote in an email.

Doug Smith, the head of the dealers association, said in a statement Thursday that the group wants customers to have access to Tesla cars, but that the revenue department erred in allowing the automaker to sell vehicles directly.

“All we have ever requested is that any new manufacturer be treated the same as other vehicle manufacturers in Missouri, which are all required to employ a system of sales that uses an automobile dealer to deliver the vehicle to Missouri consumers,” Smith said.

Tesla has faced similar roadblocks to selling its cars in several states with dealership laws similar to Missouri’s. In some of those states, legislators have been looking at ways to tweak laws and let the company operate.