NEW YORK (CNNMoney) -- Mortgage financing giant Fannie Mae Tuesday reported a record profit of $17.2 billion for 2012, a testament to how much the housing market has improved lately.
Just four years ago, the government had to step in and take control of Fannie Mae, which was brought down to its knees by deep losses from foreclosures and plunging home prices after the real estate bubble had burst.
It was the first full year profit reported by the company since 2006, and marked a significant turnaround from the $16.9 billion loss it posted for 2011.
It also means that Fannie Mae is poised to pay tens of billions of dollars in additional dividends to the U.S. Treasury, perhaps as soon as this quarter, in what could turn out to be its largest repayment to date. The government has pumped in $116 billion in bailout funds in its rescue of the company.
Fannie's improvement in results stems directly from a sharp drop in losses on its loan portfolio. That's because of the decline in foreclosures and delinquencies on the mortgages it owns or guarantees.
The company said it expects its "earnings to remain strong over the next few years."
The housing market has enjoyed a significant recovery in the past year, as low mortgage rates and a tight supply of homes has combined to drive up home prices and sales.
A settlement payout from Bank of America also raised Fannie's 2012 pre-tax income by $1.3 billion. Bank of America agreed to pay the mortgage financier $3.6 billion as part of a settlement over risky mortgages that Countrywide Financial sold Fannie during the housing bubble. Countrywide was subsequently bought by Bank of America.
The 2012 profit was more than twice the company's previous record of $8.1 billion in 2003, at a time when the housing bubble was just starting to inflate. Fannie's $7.6 billion profit in the final three months of the year also represented its best quarter on record.
Any improvement in Fannie's results is particularly good news for taxpayers. Fannie pays dividends to the Treasury on shares that the government owns. Dividend payments totaled $11.6 billion in 2012 and $4 billion so far in 2013, bringing the total of its Treasury payments to $35.6 billion.
Another reason taxpayers should be happy about Fannie Mae's profitability is that it opens the way for the company to use an accounting treatment to reinstate past tax credits worth $59.8 billion in its balance sheet, which it can use to repay the government.