Fannie Mae earned $17.2 billion last year, the biggest annual profit in the U.S. mortgage giant's history, helped by a record fourth quarter.
The 2012 gain was driven by the housing recovery, which has reduced delinquencies and lifted home prices six years after the bubble burst.
The government-controlled company also said Tuesday that it paid dividends of $11.6 billion to the U.S. Treasury in 2012. Fannie said it expects to remain profitable "for the foreseeable future."
The company did not see any federal assistance in 2012. That followed a year in which the company reported a net loss of $16.9 billion and requested $25.9 billion in federal assistance.
Taxpayers spent $188 billion to rescue Fannie and smaller sibling Freddie Mac from their exposure to risky loans that triggered the 2008 financial crisis. Fannie received $116 billion and has paid back $35.6 billion.
Freddie received $72 billion and has paid back nearly $20 billion.
The gradual recovery of the housing market has enabled both companies to become profitable again. Freddie has posted positive net earnings for the past five quarters.
Fannie earned $7.6 billion in the October-December quarter, a quarterly record for the company. Half of the gain came from a legal settlement with Bank of America. Fannie paid the Treasury Department a quarterly dividend of $2.9 billion.
Under a federal policy adopted last summer, Fannie and Freddie must turn over their quarterly profits to the government.
The fourth-quarter earnings compared with a net loss of $2.4 billion in the final quarter of 2011.
Fannie and Freddie together own or guarantee about half of all U.S. mortgages, or nearly 31 million home loans. Those loans are worth more than $5 trillion. Along with other federal agencies, they back roughly 90 percent of new mortgages.