In August 2012, the federal government abruptly changed the terms of the bailout provided to Fannie Mae and Freddie Mac, the mortgage finance giants that had been devastated by the financial crisis. Instead of continuing to receive payments on the taxpayer assistance, Treasury officials decided to begin seizing all the profits both companies generated every quarter.

It was an unusual move, given that the companies still had public shareholders. But it was necessary, the Treasury said, to protect taxpayers from likely future losses in their operations. Justice Department lawyers have reiterated this view in court, saying that the bailout terms were modified because the companies were in a death spiral.

But newly unsealed documents show that as early as December 2011, high-level Treasury officials knew that Fannie and Freddie would soon become profitable again. The materials also show that government officials involved in the decision to divert the profits knew the change would most likely generate more money for Treasury than the original rescue terms, which required the companies to pay taxpayers 10 percent annually on the bailout assistance they had received.

A December 2011 information memo to Timothy F. Geithner, the former Treasury secretary, is among the newly released documents. The 17-page memo from Mary John Miller, assistant secretary for financial markets, shows that the idea to extract all of Fannie’s and Freddie’s profits coincided with their anticipated turnaround.