FILE PHOTO: A Tesla logo is seen at a groundbreaking ceremony of Tesla Shanghai Gigafactory in Shanghai, China January 7, 2019. REUTERS/Aly Song

WASHINGTON (Reuters) - Tesla Inc and the state of Michigan confirmed Wednesday they have resolved the company’s 2016 lawsuit challenging the state’s refusal to allow the company to sell vehicles directly to consumers.

The Michigan Attorney General Dana Nessel’s office said a resolution filed in U.S. District Court recognizes “that any Michigan resident may lawfully buy a Tesla and have it serviced in Michigan.”

The stipulation also says Tesla may “operate under existing Michigan law; sell cars to Michigan customers as long as the sales contract indicates the sale took place in a state other than Michigan; and, indirectly own service and repair facilities in Michigan through a subsidiary, Tesla Michigan.”

Reuters and other outlets reported the expected settlement on Tuesday. Unlike other automakers, Tesla does not sell its vehicles through a network of independent dealers.

Tesla chief executive Elon Musk reacted to the settlement on Twitter writing: “Yay!” Tesla has filed a number of legal challenges over the years to state laws that prohibit or heavily restrict the ability of automakers to sell vehicles directly to consumers.

The stipulation says Tesla may operate galleries in Michigan to “educate customers and facilitate transactions out-of-state.” Tesla may conduct demonstration drives, discuss prices, service, financing, leasing, and trade-ins with potential customers and facilitate “ordering and purchase of a vehicle for which legal title transfers out-of-state.”

Tesla agreed to drop its suit and Michigan officials agreed to “take no enforcement action against Tesla or any Tesla

subsidiary” as long as it abided by the terms of the court papers.