A Richmond judge has upheld a Virginia Department of Motor Vehicles decision that enabled the electric automobile maker Tesla Inc. to open a company-owned dealership in Henrico County over the objections of the Virginia Automobile Dealers Association.

In a ruling issued Friday, Judge Gregory L. Rupe of Richmond Circuit Court affirmed a 2016 decision by Virginia DMV Commissioner Richard D. Holcomb that California-based Tesla could open its own store in Henrico County, but the judge also expressed misgivings about that decision.

The Virginia Automobile Dealers Association, a powerful trade group for independent dealerships in the state, opposed Tesla’s petition on the grounds that state law prohibits automobile manufacturers from owning dealerships except under limited exceptions. The trade group appealed Holcomb’s decision to Richmond Circuit Court.

Despite the legal challenge, Tesla opened its store at 9850 W. Broad St. in western Henrico in August 2017. The store is still selling and servicing cars, even though Tesla announced in March that it planned to close about half its showrooms worldwide.

Don Hall, president and chief executive officer of the Virginia Automobile Dealers Association, said Friday that he was conferring with the group’s membership and would comment on the court ruling at a later time. The ruling could be appealed.

In a statement, Tesla said it was pleased with the decision.

“The ruling is a win for consumers who are increasingly looking to purchase electric vehicles,” the company said. “We look forward to continuing to serve our customers and grow our business across the commonwealth.”

The state statute at issue in the legal battle says an automobile manufacturer must sell its cars through independent dealerships in Virginia unless no dealership is available in a community that can do so “in a manner consistent with the public interest.”

Tesla, which was founded by tech industry tycoon Elon Musk, has argued that its direct-to-consumer business model means no independent dealer could sell its cars profitably, and thus no dealer could do so in a manner consistent with the public interest.

Holcomb agreed and granted the company’s petition to open a store, even though a DMV hearing officer had previously recommended that Tesla’s application be denied.

While his ruling upheld Holcomb’s decision, Rupe also expressed “serious concerns about the evidence in this case.”

Rupe said the state statute “gives broad discretion to the [DMV] commissioner,” and the court may reverse the commissioner “only when he acts arbitrarily or capriciously.”

“Although this court disagrees with his [Holcomb’s] analysis, it has no doubt that the commissioner felt that he is serving the best interests of the people of this commonwealth,” Rupe wrote. “And the commissioner’s decision is supported by the evidence in this case.”

However, Rupe also wrote that he is “troubled by the implications of the Tesla business model,” which he said circumvents the intentions of the state statute.

“Tesla’s business model artificially creates a situation where it seems no independent dealer could be profitable,” the ruling says. “Accepting such a business model lets the tail wag the dog.”