When Tesla acquired SolarCity in 2016, the $2.6 billion deal was criticized by many as a bailout by Elon Musk and for Elon Musk, who was the biggest shareholder of both the electric carmaker and the solar panel distributor.

In an explosive 114-page lawsuit filed on Tuesday, Walmart piled onto the controversy, highlighting the familial ties between Tesla and SolarCity as the underpinnings of a flawed merger that allegedly produced shoddy craftsmanship and led to fires at seven Walmart stores.

"On information and belief, when Tesla purchased SolarCity to bail out the flailing company (whose executives included two of Tesla CEO Elon Musk's first cousins), Tesla failed to correct SolarCity's chaotic installation practices or to adopt adequate maintenance protocols, which would have been particularly important in light of the improper installation practices," Walmart said in the suit filed in New York. SolarCity co-founders Lyndon Rive and Peter Rive are Musk's cousins.

Already faced with a slumping stock price from dozens of lawsuits and investigations, store closings, delayed loan repayments and the departure of key executives, the Walmart suit lands at a particularly difficult time for Tesla and Musk. Specifically in regards to SolarCity, Musk was slated to be deposed earlier this month in a complaint brought by shareholders over the deal.

After the SolarCity deal, by far Tesla's biggest ever, the company had plans for a factory in Buffalo, New York, that it was sharing with battery manufacturing partner Panasonic. The facility was intended to focus on solar panels but turned into a site for making parts for its Supercharger and energy products. Tesla has reportedly taken $62 million in impairment charges after ditching research and development work related to batteries and solar technology.

Walmart's suit against Tesla alleges breach of contract, gross negligence and failure to live up to industry standards. The retailer is asking Tesla to remove solar panels from over 240 store locations where they've been installed and to pay damages its says are related to fires caused by those panels.

Some of the most detrimental claims in the suit relate to employees' lack of "solar training and knowledge" and inability to identify and properly install basic equipment. According to the suit, Tesla's own inspection reports revealed "improper wire management, including abraded and hanging wires," as well as "poor grounding" and "solar panel modules that were broken or contained dangerous hotspots."

The name SolarCity shows up 46 times in the lawsuit, which alleges the company had a failed business model, stemming from a goal to speed up revenue growth at all costs.

"Walmart's experience bears out Tesla, Inc.'s and Tesla's inability to turn around and bail out the solar panel operations acquired from SolarCity," the suit says.

Tesla shares dropped more than 1% after hours on the news.

Walmart declined to comment. Tesla did not respond to requests for comment.

— Lora Kolodny contributed to this report

WATCH: Walmart sues Tesla after solar panels on stores catch fire