The state of Michigan on Wednesday filed to settle a Tesla Inc. lawsuit that will allow the Silicon Valley automaker to sell directly to customers living in the home state of the Detroit Three.

The agreement ending a six-year feud will allow Michigan car buyers to purchase Tesla's electric vehicles, which could test existing automakers and dealers across the state. The ability for Tesla to sell directly to customers without using dealerships or subsidiaries comes as its competitors ramp up production of electric vehicles.

The settlement "recognizes that any Michigan resident may lawfully buy a Tesla and have it serviced in Michigan," Kelly Rossman-McKinney, a spokeswoman for Attorney General Dana Nessel's office, said in a statement.

Tesla had been barred from opening service stations in the state, or selling its vehicles directly to customers since October 2014 when former Gov. Rick Snyder signed a bill into law that he said "clarifies and strengthens” an existing statute that prohibited direct sales of new cars to protect dealers.

The agreement Wednesday determines existing law does not prohibit "Tesla from delivering vehicles to Michigan residents in Michigan (whether directly, through a subsidiary, using an independent carrier, or otherwise), including assisting them with vehicle trade-ins, so long as legal title for any vehicles sold by Tesla transfers outside the state of Michigan," according to Wednesday's filing. A Michigan resident later could transfer the title in Michigan.

The company also may operate service and repair facilities in the state, but it must be through a subsidiary, which Rossman-McKinney identified as "Tesla Michigan." A Plymouth-based entity under the name Tesla Michigan Inc. was registered with the Michigan Department of Licensing and Regulatory Affairs on Dec. 4.

The lifted restrictions could be a dramatic change for Tesla owners, who had to travel to Cleveland, Columbus, or even Chicago to obtain their vehicles or have them serviced. To meet Michigan demand, the automaker opened a service center in Toledo, part of CEO Elon Musk's push to expand Tesla's service network.

Tesla did not immediately have comment on Wednesday, though Musk on Tuesday replied to a tweet posted by The Detroit News on the expected agreement with enthusiasm: "Yay!"

The settlement also allows Tesla to continue operating galleries in the state like its storefront in Troy's Somerset Collection Mall. Those working at the gallery were previously barred from initiating or assisting any sale of a vehicle, but the state now says that test drives, price discussions, facilitating ordering and purchasing a vehicle and assisting with purchasing paperwork for a sale are permissible activities.

The automaker has fought since at least 2014 to sell its vehicles directly to consumers in Michigan. The state laws blocking Tesla from selling its vehicles were originally established to prevent unfair competition between vehicle manufacturers and affiliated dealers. They also prevent arbitrary closings of dealerships by automakers.

Before an amendment to Michigan law in October 2014, Tesla believed it had a right to not just open a retail store but a full dealership. GM and Ford supported the so-called “anti-Tesla” bill that was initiated by the Michigan Automobile Dealers Association in 2014, a bill state officials insisted was not anti-Tesla.

The Michigan Automobile Dealers Association did not immediately have comment.

Staff writer Ian Thibodeau contributed.

bnoble@detroitnews.com

Twitter: @BreanaCNoble