(Bloomberg) -- The U.S. Supreme Court agreed to decide whether investors can challenge the 2012 agreements that let the federal government collect hundreds of billions of dollars of Fannie Mae and Freddie Mac’s profits.

The justices said they will hear an appeal by President Donald Trump’s administration of a ruling that would force the government to defend against a shareholder lawsuit. The investors say the agreements exceed the authority of the Federal Housing Finance Agency, which regulates the two mortgage giants.

Fannie jumped 9% to $2.29 in New York trading as of 2:23 pm. Freddie also rose 9% to $2.28.

A ruling in the investors’ favor would give them a chance to collect a massive settlement. Fannie and Freddie have paid more than $300 billion in dividends to the Treasury under the so-called net-worth sweep.

The administration told the court the dispute “is of immense practical importance.” The justices will hear the case in the nine-month term that starts in October.

Fannie Mae and Freddie Mac keep the U.S. housing market humming by buying mortgages from lenders and packaging them into bonds that are sold to investors with guarantees of interest and principal.

‘Cloud of Uncertainty’

After the housing market cratered in 2008, the companies were put into federal conservatorship and sustained by taxpayer aid. They have since returned to profitability and paid $115 billion more in dividends to the Treasury than they received in bailout funds. Since 2013, most of their profits have been sent to the Treasury under the net-worth sweep.

The administration contends the 2008 law that set up the FHFA precludes lawsuits that challenge the profit sweep. The law bars courts from doing anything to “restrain or affect the exercise of powers or functions of the agency as a conservator.”

A splintered New Orleans-based federal appeals court let the lawsuit go forward, saying the FHFA wasn’t acting as a conservator when it agreed to the net-worth sweep.

The suing shareholders said the appeals court reached the right conclusion. But they nonetheless urged the Supreme Court to hear the Trump administration appeal, saying all sides would benefit from clarity.

“So long as there is a credible threat that litigation will invalidate the net-worth sweep, a cloud of uncertainty will hang over the companies’ capital structure,” the shareholders told the Supreme Court. “Investors will not be willing to supply the tens of billions of dollars in new capital that are essential to Treasury’s reform plan.”

Trump administration officials, including Treasury Secretary Steven Mnuchin, have long stated that they want to end federal control by releasing Fannie and Freddie from conservatorship. Wall Street analysts have said they are skeptical of that happening before the November election, meaning the administration’s goal largely depends on Trump winning a second term.

The government’s appeal is Mnuchin v. Collins, 19-563.

(Updates with shares in third paragraph)

©2020 Bloomberg L.P.