Fannie Mae helped by the housing market's continued recovery, posted an $17.2 billion annual profit for 2012 on Tuesday, its largest ever yearly gain and its first in six years.

Mortgage finance giant Fannie Mae and its smaller sibling company Freddie Mac are returning to health as home prices have leveled off and mortgage delinquencies have dampened. 

Fannie Mae said in its filing that it did not book a tax-related gain that could have been as much as $59 billion that would have fueled earnings and allowed the company to make an enormous one-time payment to the U.S. Treasury to reduce remaining bailout funds.

The company had missed its March 18 filing deadline for its fourth-quarter financial results and said it needed more time to analyze those so-called deferred tax assets, which are unused credits that can be used to cover future tax bills.