The rules of the road are being rewritten in Connecticut — by Tesla.

To the chagrin of traditional auto dealerships, the high-end electric car manufacturer won a favorable court ruling last week over the location of its swanky Greenwich showroom, its only one in the entire state.

Not that Tesla refers to it as a showroom. It’s a “gallery.”

A state Superior Court judge in Stamford dismissed a May 2016 lawsuit by the Connecticut Automotive Retailers Association (CARA) against Tesla and the town’s Zoning Board of Appeals over the permitting process for the unorthodox flagship store. The thrust of the complaint was that Tesla is operating a miniature car dealership along the town’s main shopping thoroughfare, which traditional automakers say violates zoning regulations and puts them at a competitive disadvantage.

The ruling sets the stage for an anticipated legislative showdown between car dealerships and Tesla, which has been seeking regulatory approval to sell its vehicles directly to consumers in Connecticut. New York and Massachusetts, by contrast, allow direct sales.

“We agree with the decision of the judge and encourage legislators to contemplate the benefits Tesla can bring the state, if allowed,” Tesla said in a statement. “It is unfortunate that CARA’s efforts, if successful would impair consumer choice, limit economic growth and negatively impact public health. We will continue to educate Connecticut consumers on the benefits of sustainable energy in the meantime, and look forward to a permanent solution.”

CARA, which represents 300 dealers in the state, downplayed the significance of the ruling. The scope, it said, was limited to whether car dealers had standing in a local zoning matter.

“There are several options remaining to continue to ensure that Tesla follows the law, and we plan to pursue them,” said Jim Fleming, president of the car retailers’ group. “Today, Tesla could choose to work within the current franchise system that local dealers have invested in. This system creates price competition, maintains good paying local jobs in Connecticut, and advocates for consumers when there is a recall or defect. Allowing any manufacturer to skirt our existing state laws creates an uneven playing field.”

Last year, a bill that would allow Tesla to make direct sales in the state died in the Legislature after a intensive lobbying effort by competing automakers. Tesla would have been able to open two retail locations under the legislation, in addition to its existing vehicle maintenance facility in Milford. A previous version of the bill would have permitted three retail locations.

“I think the Tesla bill is coming back this year,” said Senate Majority Leader Bob Duff, D-Norwalk, who helped shepherd the proposal last session.

Duff was noncommittal on whether he would reprise his role, however.

“I tried in good faith to find an agreement, but the goalposts kept moving,” he said.

Despite the setback, Tesla opened its flagship gallery at 340 Greenwich Ave. last October with approval from the town’s Zoning Board of Appeals, which was also named as a defendant in the lawsuit. A request for comment was left Tuesday with the town attorney.

Tesla’s most popular models, including the Model S sedan, are on display in the storefront, in addition to Tesla clothing and merchandise.

The town’s Planning and Zoning Commission and zoning enforcement officer previously denied Tesla’s bid to open a location on Greenwich Avenue. The electric car maker successfully appealed to the town after agreeing not to conduct sales or test drives at the location. It was also prevented from having a charging station on site.

neil.vigdor@scni.com; 203-625-4436; http://twitter.com/gettinviggy