Tesla Inc. is replacing its general counsel with a seasoned trial lawyer who has decades of experience defending corporate interests.

Todd Maron, Tesla’s top lawyer and a confidant of Chief Executive Elon Musk, is departing the company after more than five years, the company said in response to questions from The Wall Street Journal. He will stay on to help with the transition until January.

The...