Elon Musk has sold US$6.9 billion ($9.8 billion) worth of his Tesla shares ahead of a potential legal battle with Twitter. 

In early July, Mr Musk bailed on an agreement to buy Twitter for $44 billion, leading Twitter to sue Mr Musk to force him to complete the transaction.

Mr Musk had claimed that Twitter misled him about the number of spam accounts on the platform, but the social media giant has dismissed this as simple buyer's remorse. 

Mr Musk has since countersued, though the details of his legal action have not been revealed. 

The Tesla boss explained his stock sale on the very platform he is fighting. 

“In the (hopefully unlikely) event that Twitter forces this deal to close *and* some equity partners don't come through, it is important to avoid an emergency sale of Tesla stock,” he said in a tweet this week. 

Twitter and Mr Musk will head to trial on October 17.