A federal appeals court has rejected a shareholder appeal in a lawsuit challenging the U.S. government's ability to seize all of the quarterly profits generated by Fannie Mae and Freddie Mac after the companies' bailout amid the 2008 financial crisis.

In a precedential opinion, a three-judge panel of the U.S. Court of Appeals for the Third Circuit ruled Wednesday that the federal agency created to oversee the government-sponsored firms was acting within its power in 2012, when it changed the bailout terms, for the third time, to force the Fannie and Freddie to pay the U.S. Department of the Treasury quarterly dividends equal to their net worth.

In place since 2013, the so-called “net worth sweep” has allowed the Treasury to reclaim hundreds of billions of in taxpayer funds it spent to bail out the companies at the height of the crisis. Shareholders, however, argued that the revised terms violated Delaware and Virginia corporate law and have allowed the Treasury to scoop up billions of dollars in company profits, while investors received nothing.

U.S. District Judge Gregory M. Sleet of the District of Delaware dismissed the suit last November, ruling that the net worth sweep was consistent with the Federal Housing Finance Agency's mandate under the Housing and Economic Recovery Act of 2008 to ensure the companies' survival.

On appeal, the shareholders David Jacobs and Gary Hindes reprised their arguments from the lower court and said they were entitled to share in future profits that now flow to the government.

Third Circuit Judge Stephanos Bibas acknowledged that Fannie and Freddie's shareholders were in a “tough spot,” but he said the Recovery Act gave the government “broad, discretionary power” to enter the deal. According to Bibas, the net worth sweep was consistent with the corporate laws of Delaware and Virginia—come to Fannie and Freddie, respectively—and the monetary relief the plaintiffs requested would undermine its purpose.

“The request for damages, disgorgement, and restitution, against both the agency and the Treasury, would (as the challengers concede) unravel the third amendment [to the bailout], reverse the monetary payments made under it, and prevent or at least deter the agency from implementing it further,” Bibas said in a 25-page opinion.

He was joined in the opinion by Judges Thomas M. Hardiman and Cheryl Ann Krause.

The FHFA, designated as the companies' conservator, is tasked with preserving corporate assets until Fannie and Freddie are able to operate on their own again. The agency still retains control over both firms, which are privately owned but established by a congressional charter.

Fannie and Freddie increase liquidity in the mortgage market by buying mortgages from lenders and then packaging them into mortgage-backed securities with guaranteed payment of principal and interest.

Both companies suffered massive losses during the 2008 financial meltdown, leading to the federal bailout. The FHFA took control of the companies in July of that year, initially requiring that taxpayers be repaid with fixed quarterly dividends equal to 10 percent of the government's infusion.

The rules were changed in 2012, sparking lawsuits in Delaware, Washington, D.C., Kentucky and elsewhere.

The U.S. Court of Appeals for the Fifth Circuit rejected a similar challenge to the net worth sweep in July, but ruled that the agency itself was unconstitutional, potentially setting up a showdown before the U.S. Supreme Court.

An attorney for Jacobs and Hindes declined to comment Thursday, and attorneys for Fannie and Freddie did not immediately return calls seeking comment on the ruling.

The shareholders were represented by Myron T. Steele, Michael A. Pittenger, Christopher N. Kelly and Alan R. Silverstein of Potter Anderson & Corroon in Wilmington.

The FHFA, Freddie and Fannie were represented by David B. Bergman, Howard N. Cayne, Ian S. Hoffman, Dirk Phillips and Asim Varma of Arnold & Porter Kaye Scholer; Meaghan M. Vergow of  O'Melveny & Myers; and Michael J. Ciatti of King & Spalding in Washington, D.C.

The case was captioned Jacobs v. Federal Housing Finance Agency.