Elon Musk's huge Twitter investment took a new twist this week with the filing of a lawsuit alleging that the billionaire illegally delayed disclosing his stake in the social media company so he could buy more shares at lower prices.

The complaint in New York federal court accuses Mr Musk of violating a regulatory deadline to reveal he had accumulated a stake of at least 5%.

Instead, according to the complaint, Mr Musk did not disclose his position in Twitter until he had almost doubled his stake to more than 9%.

That strategy, the lawsuit alleges, hurt less wealthy investors who sold shares in the San Francisco company in the nearly two weeks before Mr Musk acknowledged holding a major stake.

Mr Musk's regulatory filings show that he bought a little more than 620,000 shares at 36.83 dollars apiece on January 31 and then continued to accumulate more shares on nearly every single trading day through to April 1.

Mr Musk, best known as CEO of electric car maker Tesla, held 73.1 million Twitter shares as of the most recent count on Monday. That represents a 9.1% stake in Twitter.

The lawsuit alleges that by March 14, Mr Musk's stake in Twitter had reached a 5% threshold that required him to publicly disclose his holdings under US securities law by March 24. Mr Musk did not make the required disclosure until April 4.

That revelation caused Twitter's stock to soar 27% from its April 1 close to nearly 50 dollars by the end of April 4's trading, depriving investors who sold shares before Mr Musk's improperly delayed disclosure the chance to realise significant gains, according to the lawsuit filed on behalf of an investor named Marc Bain Rasella.

Mr Musk, meanwhile, was able to continue to buy shares that traded in prices ranging from 37.69 dollars to 40.96 dollars.

The lawsuit is seeking to be certified as a class action representing Twitter shareholders who sold shares between March 24 and April 4, a process that could take a year or more.

Jacob Walker, one of the lawyers that filed the lawsuit against Mr Musk, told the Associated Press that he had not reached out to the Securities and Exchange Commission about Mr Musk's alleged violations about the disclosure of his Twitter stake.

"I assume the SEC is well aware of what he did," Mr Walker said.

An SEC spokesperson declined to comment.

Mr Musk did not immediately respond to a request for comment posted on Twitter, where he often shares his opinion and thoughts.

Mr Musk has since said he wants to buy Twitter outright.