Fannie Mae revealed plans on Thursday to write the Treasury Department a check for a whopping $59.4 billion as part of a tax maneuver after the government-controlled mortgage giant earned a record pre-tax profit of $8.1 billion in the first quarter amid the rebounding housing market.

The swelling profits and ability to return cash to the government, rather than the other way around, underscores the meaningful improvements in the housing market following the worst financial crisis since the Great Depression.

Fannie Mae, which was brought under government control in 2008, reported pre-tax income of $8.1 billion in the first quarter, compared with $2.7 billion in the year-earlier period and $7.6 billion in the fourth quarter.

The mortgage giant said that marks its fifth-consecutive quarterly profit and largest in history. The improvement was fueled by jumping home prices, including higher average sales prices on Fannie-owned properties, as well as a decline in the number of delinquent loans and a resolution agreement with Bank of America (BAC).

By comparison, Fannie suffered massive losses in the wake of the housing bust, highlighted by annual losses of $58.7 billion in 2008 and $72 billion in 2009.

Thanks to the improving results and expectations for future profits, Fannie decided to reverse deferred tax assets of $50.6 billion, sending its net income surging to $58.7 billion. Comprehensive income totaled $59.3 billion in the first quarter, compared with just $3.1 billion the year before.

The release of the tax allowance, coupled with profits, allowed Fannie to agree to a dividend payment of $59.4 billion to taxpayers in the second quarter.

That brings Fannie’s total payments to the Treasury to $95 billion, compared with $116.1 billion in aid received. Fannie’s sister mortgage giant, Freddie Mac, has repaid about $36.6 billion to the government, compared with $71.3 billion in bailout funds.  

Follow Matt Egan on Twitter @MattMEgan5