Fannie Mae and Freddie Mac surged to four-month highs on speculation lawsuits involving the mortgage giants have progressed in a way that favors shareholders.

The stocks rose the most in almost three years on Tuesday after The New York Times reported that a federal judge ordered documents unsealed in a long-standing legal dispute with shareholders. The two extended gains today. The ruling may clear the way for the case to proceed to a trial that could loosen the government’s grip, including ending the transfer of profits to the Treasury known as a net-worth sweep.

"The unsealing by the judge further suggests that she is sympathetic to the plaintiff shareholders," said Elliott Stein, senior litigation analyst at Bloomberg Intelligence. "The content of the documents undercuts some of the government’s arguments for why it implemented the net worth sweep."

The move may be seen as a boost to hedge funds including Pershing Square Capital Management and Fairholme Capital Management, which have holdings in the companies' common and preferred shares, according to data compiled by Bloomberg.

Fannie Mae shares have rallied 52% in the past two days to $2.02 as of 3:20 p.m. in New York, the highest level since Dec. 7. Freddie Mac's stock is up 44% since Monday.

Hedge funds have sued over terms of the U.S. conservatorship that call for all Fannie Mae and Freddie Mac profits to be turned over to the Treasury as dividends on the $187.5 billion bailout the companies received after the 2008 financial crisis. The dividends, which have surpassed the amount of taxpayer aid the companies got, aren't counted as repayment and leave them with no path out of government control.

Citing depositions unsealed by Judge Margaret Sweeney, who's presiding over the litigation, The New York Times noted testimony that Fannie Mae and Freddie Mac will be profitable going forward, undermining the Treasury's argument that it is entitled to all earnings as a means to protect taxpayers from future losses.

"In our non-legal expert view, there is sufficient information in these documents that indicate Fairholme's takings claim is valid," wrote Edwin Groshans, an analyst at Height LLC, in a note today. "This should result in the case proceeding to trial."

Fairholme will have to prove that the Treasury knew its actions would result in taking of earnings totaling tens of billions of dollars, according to Groshans. "This will not be an easy task, but just based on these few documents it appears that Fairholme actually may have a good opportunity to win the case," he said.

Bloomberg News