Tesla CEO Elon Musk will step down as chairman of the electric automaker and pay a $20 million fine under a settlement reached with the U.S Securities and Exchange commission. Musk will remain CEO and he will still keep a seat on the board, just not as chairman.

The agreement settles what could have turned into a bitter and potentially damaging fight for Musk, the company, and Tesla shareholders.

Musk will resign from his role as chairman of the Tesla board within 45 days of the agreement, which was filed Saturday. He has agreed to not seek reelection or accept an appointment as chairman for three years. An independent chairman will be appointed, under the settlement agreement.

Tesla will pay a separate $20 million penalty, according to the SEC. The SEC said the charge and fine against Tesla is for failing to require disclosure controls and procedures relating to Musk’s tweets.

Musk doesn’t have to admit or deny the SEC’s allegations as part of the agreement.

Tesla has also agreed to appoint two new independent directors to its board and establish a new committee of independent directors and put in place additional controls and procedures to oversee Musk’s communications, according to the SEC. This likely means that Musk, who frequently turns to Twitter to unveils new products, features and updates on his multiple companies, will be more restricted moving forward. At least when it comes to his tweets about Tesla.

“The resolution is intended to prevent further market disruption and harm to Tesla’s shareholders,” Steven Peikin, co-director of the SEC’s Enforcement Division said in a statement.

The agreement marks the beginning of a new era of corporate governance for Tesla, which some shareholders have argued is too tightly controlled by Musk and others closely aligned to him such as his brother Kimbal Musk. Investor and founding board member Steve Jurvetson is still on leave.

In 2017, Tesla diversified its board and added James Rupert Murdoch, the CEO of Twenty-First Century Fox Inc., and Linda Johnson Rice,Chairman and CEO of Johnson Publishing Company.

Other board members include: Robyn Denholm, who joined the board in 2014, Brad W. Buss, who has been on since 2009, Antonio Gracias, and Ira Ehrenpreis, one of longest-serving board members who joined in 2007.

The SEC filed a complaint Thursday in federal district court alleged that Musk lied when he tweeted on August 7 that he had “funding secured” for a private takeover of the company at $420 per share. Federal securities regulators reportedly served Tesla with a subpoena just a week after the tweet. Investigations can take years before any action is taken, if at all. In this case, charges were filed just six weeks later.

The SEC said in the complaint that Musk violated anti-fraud provisions of the federal securities laws. The commission has asked the court to fine Musk and bar the billionaire entrepreneur from serving as an officer or director of a public company.

Musk described fraud charges an “unjustified action” that has left him “deeply saddened and disappointed.”

Tesla and the board later issued a joint statement supporting Musk.

The complaint contains a number of eye-browing raising details, including that he had talked to the board about an offer to take Tesla private as early as August 2 when he sent to Tesla’s board of directors, chief financial officer and general counsel an email with the subject, “Offer to Take Tesla Private at $420.”