Tesla Motors will be able to continue to sell cars in New York state, and may eventually move to the dealership model that it has always fought.

Tesla (TSLA) and the New York Automobile Dealers Association have reached a compromise in their battle over Tesla's existing five stores in New York City and surrounding suburbs.

The dealers had been pushing to shut down the stores, charging that they violated dealership laws that prohibit selling directly to customers. All other automakers rely on independently-owned dealers to sell cars.

The dealers are a powerful political lobby in most states and seek to prohibit direct sales.

As part of the compromise announced late Friday, Tesla can continue to operate its existing stores but new ones will be allowed only through dealerships.

Tesla said it is happy with the agreement, an indication that it plans dealerships in the future.

Tesla has argued that it needs direct sales to consumers so its own sales people can explain the advantages of electric cars. It says that if it had to use dealers who also sell cheaper, gas powered cars, the dealers would neglect the Tesla Model S, which has a starting price of $69,000.

Tesla is aiming to introduce a cheaper electric car in about three years. It hopes to sell about 500,000 cars per year by 2020, up from 35,000 expected in 2014. Tesla's own company filings concede that the lack of an outside dealership network would limit increased sales of the car.

The agreement in New York comes days after Tesla got a delay on a ban on sales in neighboring New Jersey.

New Jersey had been set to prohibit the two Tesla stores from selling cars starting April 1, but this past week it agreed to delay that ban on sales until at least April 15. And legislators and members of the New Jersey dealership association are talking about a compromise that would allow Tesla sales to continue long-term, if not indefinitely.

Interactive map: Where you can buy a Tesla