Faced with a devastating court ruling, Xerox on Tuesday threw in the towel, firing its CEO and half of its board of directors to resolve a proxy contest.

It's a stunning victory for King & Spalding lawyers and their client Darwin Deason, the company's third-largest shareholder, as well as for its largest shareholder, Carl Icahn, who shared the cost of litigating the case. It was also a win for Grant & Eisenhofer, Bernstein Litowitz and Kessler Topaz representing a group of institutional holders of Xerox stock.

On Friday, Manhattan State Supreme Court Justice Barry Ostrager enjoined the company's “massively conflicted” merger with Fujifilm Holding Co., which would have provided no cash payment to Xerox shareholders. The judge also greenlighted the election of new board members at an upcoming shareholder meeting.

Xerox—citing “the significant risk and uncertainty of a prolonged litigation” (which by all indications, it was going to lose)—instead reached an agreement with Deason and Icahn.

“The Xerox Board of Directors determined that an immediate resolution of the pending litigation and proxy contest is in the best interest of our company and all stakeholders” the company said.

Under the agreement, Xerox will appoint six new board members and fire its CEO Jeff Jacobson. Keith Cozza, the CEO of Icahn Enterprises, is expected to be elected chairman of the Board of Directors of Xerox.

“[T]he new Board of Directors plans to meet immediately to, among other things, begin a process to evaluate all strategic alternatives to maximize shareholder value, including terminating or restructuring Xerox's relationship with Fujifilm and the proposed transaction with Fujifilm,” according to a press release announcing the settlement.

The Xerox board last fall was planning to replace Jacobson as CEO. Instead, he quickly negotiated a deal where Fuji would acquire a 50.1 percent controlling interest in Xerox, and he would get to stay on as chief executive. Multiple board members would get to keep their seats as well.

The settlement between Deason, Icahn and Xerox does not resolve Deason's claims against Fujifilm for aiding and abetting Xerox board members in breaching their fiduciary duties.

The King & Spalding team includes Israel Dahan, Richard Marooney Jr., Peter Isajiw and Robert Meadows.

“We believe Friday's decision and this agreement mark a watershed moment for corporate governance generally and for Xerox specifically,” Icahn said in a statement. “Thanks to our efforts and the courage and conviction of Darwin Deason, this is once again an exciting time to be a Xerox stakeholder.”