Tesla CEO Elon Musk settled a fraud suit with the Securities and Exchange Commission (SEC) by agreeing to pay a $20 million fine and he will step down as chairman of Tesla's board in 45 days, the SEC announced Saturday. Musk had been accused of misleading investors when he tweeted that he was thinking of taking Tesla private.

The SEC said it had added an additional charge that Tesla had failed to have required disclosure controls and procedures relating to Musk's tweets. That charge is included in the settlement.

Tesla will pay an additional $20 million.

Get Breaking News Delivered to Your Inbox

As part of the settlement, Musk will step down as chairman of the board and will be replaced by an independent chairman, the SEC said. Musk is ineligible to be re-elected chairman for three years, but he can stay on as CEO.

On Aug. 7, Musk tweeted that he had the funding in place to take Tesla private at $420 a share. Tesla later said details about the funding still had to be worked out with Saudi Arabia's Public Investment Fund. The SEC alleged that Musk knew the funding was uncertain, and had yet to discuss numerous contingencies.

After Musk's tweet, Tesla's stock jumped by over 6 percent on Aug. 7, the SEC said.

On Aug. 25, Musk said he had worked with investment firms Goldman Sachs, Morgan Stanley and Silver Lake to consider all the options and decided not to take the company private.

But since that tweet, the market value of Musk's electric-car company has fallen $19.6 billion, with Tesla shares sliding more than 30 percent.

The tweet is just one example of bizarre behavior by Musk recently, especially on social media. Earlier this summer, he tweeted that a British cave diver involved in the rescue of 12 boys and their soccer coach trapped in a cave was a "pedo." He then apologized and deleted the tweet, but then in September, he doubled down on the allegation to BuzzFeed News. The diver, Vernon Unsworth, filed a lawsuit in Sept. in federal court in Los Angeles alleging $75,000 in damages.

After a Reveal report in April accused Tesla of neglecting multiple reports of safety issues at its factories, Tesla issued a statement calling it an "ideologically motivated attack by an extremist organization working directly with union supporters to create a calculated disinformation campaign against Tesla." When a ProPublica reporter defended Reveal, which is run by the nonprofit Center for Investigative Reporting, Musk responded with a tweet calling the reporters "some rich kids in Berkeley who took their political science prof too seriously."

Musk then tweeted he was thinking of "create a site where the public can rate the core truth of any article & track the credibility score over time of each journalist, editor & publication. Thinking of calling it Pravda."