A judge approved Tesla CEO Elon Musk's settlement with the Securities and Exchange Commission over allegations that Musk committed fraud when he said he had secured the funding needed to take Tesla private.

Tesla shares jumped nearly 5 percent on the news, which was first reported by Bloomberg.

The deal is a positive development for Musk and Tesla, which is in the midst of ramping up production and deliveries of its Model 3 sedan and trying to assure investors the company can become sustainably profitable.

Musk and the SEC had filed a joint letter late Wednesday saying the terms of their settlement would be in the best interests of investors.

Under the terms of the deal, Musk has to pay a $20 million fine and step down as Tesla chairman within 45 days for a period of at least three years. Tesla must also put in place a system for monitoring Musk's statements to the public about the company, whether on Twitter, blog posts or any other medium.

Tesla will have to pay a separate $20 million fine, and appoint two independent directors to the board. One of those can be the chairman that replaces Musk, provided that person comes from outside Tesla and its affiliates.

Musk has neither admitted nor denied any wrongdoing.

All things considered, the outcome was pretty favorable to Musk, said Jay Dubow, a partner at law firm Pepper Hamilton. Dubow specializes in white-collar litigation and investigations and is co-chair of the firm's Securities and Financial Services Enforcement Group.

"The SEC got a lot of publicity and a lot of money in the scheme of things, for them, but I think most people will conclude he really won this battle," Dubow said. Musk is still running the company, and he has not been forced off the board.

"My guess is, the board meetings are not going to be all that different from the way they were before this," he added.

The SEC filed charges against Musk on Sept. 27, just hours after reports said Musk had rejected an initial settlement offer from the agency.

Tesla confirmed the settlement but declined to comment further.