The high-end electric car manufacturer Tesla Motors prevailed in a lawsuit filed by Massachusetts auto dealers in an attempt to stop the company from selling directly off the assembly line to customer.

The Massachusetts Supreme Judicial Court threw out a lawsuit from the Massachusetts State Automobile Dealers Association that argued that the California-based Tesla was skirting a state law that is intended to protect car dealerships from direct sales by manufacturers. The ruling on Monday stated that the original law and an amended version were designed to protect dealerships from manipulation by their brand manufacturers, rather than to prevent direct sales by non-affiliated companies.

State Sen. Marc Pacheco, D-Taunton, filed a bill in January 2013 to defend auto dealerships from the threat posed by the business model used by Tesla, with language that would clarify the current state law, emphasizing a “blanket prohibition” on manufacturer ownership of dealerships. Tesla has an installation at the Natick Mall promoting their cars, with a separate town-licensed location where they can test-drive the cars and buy them. But without a third-party dealership, the auto dealers association considers it against the spirit of the state law, which was last amended in 2002.

Pacheco said now that the judicial challenge to Tesla’s business in Natick has failed, the bill will be filed once more during the next legislative session, next year.

“There was a general feeling to wait for the courts to rule, that we may not need to go forward with legislation,” Pacheco said. “Now that they have ruled, obviously, the legislative alternative is the way to go. It’s just a matter of whether we will need to amend the existing version as filed or not, for the next session.”

Dave Rosa, a Republican from Dighton who is running against Pacheco for state senator in the 1st Plymouth and Bristol District, said that he faults Pacheco for his advocacy on the issue.

“Last year Sen. Pacheco came out against Tesla,” Rosa said. “Fighting against this clean car company shows the senator’s hypocrisy on so-called climate change. I’m glad they’re coming here. I welcome every job creator to the commonwealth, not just the ones that donate to my campaign.”

Pacheco said that his work on the state law predates Tesla coming to Massachusetts, and that he is not against Tesla or any electric car companies selling their vehicles here.

Pacheco said that the real problem is the model that disregards the third-party dealer system, which would allow foreign companies to come in and undercut a critical part of the state’s retail economy.

“This could be the Trojan horse of the foreign car market coming in and utilizing this loophole to undercut the existing system that is there,” Pacheco said. “My goal and my rationale for filing the bill are, very simply, wanting to make sure that the existing part of the retail economy remains strong, and that it is not undercut by foreign imports that can come in, utilizing this loophole and eroding that piece of the economy that has been a very important part, in particular, for the southeastern Massachusetts economy.”

Auto dealerships represent 20 percent of the Massachusetts retail economy, including 20,000 jobs at 420 locations throughout the state, according to Pacheco.

Pacheco said that foreign companies could exploit this “loophole” and sell directly “without really having the consumer protections in place that are there normally” as part of the dealer-consumer relationship, such as the Lemon Law and other standards.

Pacheco said that he has nothing against Tesla’s environmentally friendly electric cars, and that, in fact, he drives a hybrid car himself. Pacheco said that he is a strong proponent of clean energy cars, but that the Tesla models are actually far more expensive than hybrids and plug-in electric cars that are produced by major manufacturers and sold at local dealerships.

Tesla, who won the 2013 Motor Trend “Car of the Year” for the Model S, released a statement to the Gazette on Monday, celebrating the Massachusetts Supreme Judicial Court decision.

“Today’s ruling by the Massachusetts Supreme Judicial Court makes very clear that franchise practice acts are concerned with protecting auto dealers from abuses by their associated manufacturers, and are not about hindering new manufacturers like Tesla that have no franchise relationships,” said Diarmuid O’Connell, Tesla’s vice president for business development. “Rulings like this reveal that the effort to shut Tesla out of the marketplace is little more than an effort to create a de facto monopoly and force us to accept the dealers’ business model.”

O’Connell said that Tesla will ramp up its work in Massachusetts. The company said that it will eventually offer electric cars at more affordable prices, with a vehicle under $40,000 not expected for at least three more years. The Model S currently costs about $70,000.

“We look forward to expanding our business and investment in Massachusetts and continuing to advance the transition to sustainable transportation throughout the U.S.,” O’Connell said.