BOSTON — The highest court in Massachusetts has thrown out a lawsuit aimed at blocking Tesla Motors from selling its electric cars directly to consumers.

The Massachusetts State Automobile Dealers Association had sought to prevent the direct sales, citing a state law designed to block car dealers from abuses by car manufacturers.

The Supreme Judicial Court unanimously ruled Monday that the association and two dealers — Herb Connolly Chevrolet and Fisker Norwood — didn’t have legal standing to bring the case.

The court said Natick has since given Tesla a license to operate a sales office at the Natick Mall.