Tesla Inc and Elon Musk have agreed to pay $20 million each to financial regulators and the billionaire will step down as the company's chairman but remain as chief executive, under a settlement that caps a tumultuous two months for the carmaker.

The securities fraud agreement, disclosed by the U.S. Securities and Exchange Commission on Saturday, will come as a relief to investors, who had worried that a lengthy legal fight would only further hurt the loss-making electric car company.

The SEC on Thursday charged Musk, 47, with misleading investors with tweets on Aug. 7 that said he was considering taking Tesla private at $420 a share and had secured funding. The tweets had no basis in fact, and the ensuring market chaos hurt investors, it claimed.

Investors and corporate governance experts said the agreement could strengthen Tesla, which has been bruised by Musk's recent behavior, which included smoking marijuana and wielding a sword on a webcast, and attacking a British rescue diver via Twitter.

The settlement should place more oversight on Musk while not taking the “devastating” measure of forcing him out, said Steven Heim, a director at Boston Common Asset Management, which owns shares in Tesla battery maker Panasonic Corp.

Tesla must appoint an independent chairman, two independent directors, and a board committee to set controls over Musk's communications under the proposed agreement.

"The prompt resolution of this matter on the agreed terms is in the best interests of our markets and our investors, including the shareholders of Tesla," SEC Chairman Jay Clayton said in a statement.

In the settlement, the agency pulled back from its demand that Musk, who is synonymous with the Tesla brand, be barred from running Tesla, a sanction that many investors said would be disastrous.

“I think this is the best possible outcome for everyone involved” said Ivan Feinseth of Tigress Financial Partners, who rates Tesla "neutral" and who called the SEC's penalty "a slap on the wrist" for Musk.

“The fact that he can remain CEO is very important for the company."

Neither Musk nor Tesla admitted or denied the SEC's findings as part of the settlement, which still must be approved by a court. Tesla and Musk did not immediately respond to requests for comment.

HUNT FOR A STRONG CHAIR?

Musk had been directly involved in almost every detail of Tesla's product design and technology strategy, and drove the company's employees to extraordinary achievements - much as another Silicon Valley chief executive, Steve Jobs, did at Apple Inc.

The entrepreneur is now required to step down as chairman of Tesla within 45 days, and he is not permitted to be re-elected to the post for three years.

The SEC charged Tesla with failing to have required disclosure controls and procedures for Musk's tweets. The SEC said the company had no way to determine if his tweets contained information that must be disclosed in corporate filings, or if they contained complete and accurate information.

Musk walked away at the last minute from an earlier settlement with the SEC that would have required him to give up key leadership roles at the company for two years and pay a nominal fine, according to media reports on Friday. Reuters on Friday reported that Musk could settle with the SEC but was ready for a court fight.

Investors said on Friday that it has been a mistake for Musk to turn down that settlement, especially at a time when the company has been pushing hard to meet aggressive production targets for its Model 3 sedan.

The settlement tasks the Tesla board, which critics have accused of failing to rein in Musk, with the tricky challenge of finding an independent chairman able to work closely with the sometimes unpredictable chief executive.

It was not immediately clear who would be appointed to the role. Antonio Gracias, the current lead independent director and CEO of Valor Equity Partners, has been criticized as being too close to Musk and his companies.

“The question is whether Musk’s buddies on the board decide to bring in a really strong chair who will stand up to Musk,” said Erik Gordon, a University of Michigan business professor who follows corporate governance.

Musk has driven the company to the verge of profitability with a costly ramp-up of production of its Model 3 over the past year. Electric vehicle news site Electrek reported that Tesla had produced 51,000 Model 3s with a couple of days left in the quarter, hitting its goal of 50,000 to 55,000.

The CEO, who has often turned to Twitter to promote Tesla and confront critics, said on Thursday that the SEC's actions were unjustified. Tesla shares jumped after his Aug. 7 tweets, a blow to short-sellers betting on the stock's decline.

As the public face of Tesla, Musk had gained legions of fans for his bold approach to business and technology. He used his Twitter account to promote the achievements of Tesla, his rocket launch company SpaceX, and other projects such as his tunnel venture, the Boring Co, to his nearly 23 million followers.