A year ago, Mark Zuckerberg announced a complicated plan to change the shareholder structure of Facebook. The idea was to keep control of the company, and free up billions of dollars for his charitable efforts focused on curing diseases and improving education.

On Friday, he reversed that plan — days before he was set to appear in court to defend it.

Facebook’s board had approved Zuckerberg’s proposal to create a new kind of stock, known as Class C shares, that wouldn’t have rights or the ability to vote on corporate policy.

Zuckerberg, who controls the majority of voting rights in Facebook, would have sold the Class C shares and deployed those funds to a philanthropic effort he set up with his wife, Priscilla Chan.

But the stock of Facebook, which is up 31% in the past year, has done so well that Zuckerberg says he will be able to fund his philanthropy and maintain control of the company for more than 20 years.

“The idea was that it would allow me to keep voting control of Facebook so we can continue to build for the long term, but also allow Priscilla and me to fund the work we’re doing through the Chan Zuckerberg Initiative,” he wrote in a Facebook post.

Zuckerberg wrote that he and Chan still intend to donate 99% of their Facebook stock during their lives. He said he plans to sell between 35 million and 75 million shares in the next 18 months “to fund our work in education, science, and advocacy.”

Facebook closed Friday at $170.54 a share.

The reversal also allows Zuckerberg to avoid having to appear in court on Tuesday.

He was set to testify in Delaware in a lawsuit brought by shareholders who were contesting the proposed change in Facebook stock, which would have allowed Zuckerberg to keep control even while shedding shares.

“We’re thrilled that Facebook has dropped the reclassification,” shareholder attorney Stuart Grant of Grant & Eisenhofer said in a statement. Grant was preparing to cross-examine Zuckerberg at trial.

“Stopping the issuance of the non-voting C shares is all the relief we were asking for at trial. Today’s move is a total victory for stockholders.”

Non-voting shares are controversial in Silicon Valley; companies use them to allow founders to keep unfettered control of startups that grow into major companies.

“The fact that he’s withdrawing is a positive sign for those opposed to non-voting stock,” said Charles M. Elson, professor of corporate governance at the University of Delaware. “I think it signals a nervousness with the concept, and I think that will serve as a warning sign to others contemplating a similar action.”

— CNN Tech’s Seth Fiegerman and Heather Kelly contributed to this report.