SAN FRANCISCO — Mark Zuckerberg headed off a contentious legal fight with investors over creating a class of non-voting stock that would keep him in control of the company even after selling the bulk of his shares.

The Facebook CEO, who had asked for the change so he and wife Priscilla Chan could give away most of their wealth to charity and causes, credited the rise in his company’s stock price for helping him maintain voting control of the social media giant he co-founded while still spending billions on philanthropic efforts.

“Over the past year and a half, Facebook’s business has performed well and the value of our stock has grown to the point that I can fully fund our philanthropy and retain voting control of Facebook for 20 years or more,” Zuckerberg said in a Facebook post. “As a result, I’ve asked our board to withdraw the proposal to reclassify our stock — and the board has agreed.”

Facebook’s stock price has jumped more than 50% since the Silicon Valley company proposed issuing the nonvoting shares in April 2016. 

Zuckerberg made the proposal after his advisers warned he risked losing voting control over Facebook if he sold a few billion dollars’ worth of Facebook shares.

The plan to create the new class of non-voting class-C shares drew an angry response from some shareholders, who filed a class action lawsuit that sought to block it. Shareholders alleged the plan did not have their best interests at heart and could cost them billions of dollars. 

“Stopping the issuance of the non-voting C shares is all the relief we were asking for at trial,” shareholder attorney Stuart Grant of Grant & Eisenhofer said in a statement. “Today’s move is a total victory for stockholders.”

With the lawsuit behind him, Zuckerberg said he plans to accelerate selling of shares to fund his philanthropic organization, the Chan Zuckerberg Initiative. He says he plans to sell 35 million to 75 million shares over the next 18 months for a total of between $6 billion and $12 billion.

Dropping the proposal also means that Zuckerberg will not have to testify in the case, scheduled for Tuesday in Delaware Chancery Court. Other board members including Silicon Valley venture capitalist Marc Andreessen, Susan Desmond-Hellmann of the Bill & Melinda Gates Foundation and former White House…