Tesla and Walmart have partnered on several clean energy initiatives, and more than 240 stores have been fitted with solar panels from the firm.

Walmart has also pre-ordered at least 45 Tesla electric trucks to add to its vehicle fleet.

In 2016, Tesla spent $2.6bn (£2.1bn) on clean energy firm SolarCity, which was founded by Elon Musk’s cousins but, since then, installations have dropped by more than 85% and Tesla has cut its sales force and ended a distribution deal with US store Home Depot.

Mr Musk’s firm is also facing investigations from the US National Transportation Safety Board regarding fires in several Tesla cars.

Last month, the firm reported a $408m loss in second quarter earnings.

Tesla’s share price fell on news of the Walmart lawsuit, which was filed in the New York State Supreme Court on Tuesday.