Government-run Fannie Mae and Freddie Mac, the biggest providers of housing finance, plan to send the U.S. Treasury $39 billion in December, leaving them within a hair of paying back their 2008 bailout.

Freddie Mac said on Thursday that it will pay $30.4 billion in dividends after a multibillion-dollar tax-related windfall fueled a record profit in the third quarter. Fannie Mae, the bigger of the two companies, said it would make an $8.6 billion payment.

The companies, which own or guarantee about two-thirds of all U.S. home loans, were seized by the government at the height of the financial crisis as mortgage losses threatened their solvency. Their profits are now surging as the housing market rebounds.

When McLean-based Freddie Mac makes its payment in December, it will have returned all of the $71.3 billion it received in taxpayer aid, along with an additional $9 million. District-based Fannie Mae’s dividend will leave it about $2.2 billion shy of the $116.1 billion it received.

“We are quickly approaching the point when taxpayers will receive a positive return on their investment in this company,” Fannie Mae chief executive Timothy Mayopoulos said during a conference call. “That’s obviously very good news for taxpayers.”

By early next year, taxpayers probably will have turned a profit. The two firms’ bailout agreements, however, do not provide a way for them to buy back the $189 billion worth of senior preferred shares the government received in return for its aid.

Under the bailout terms, the companies will continue to make dividend payments as long as they are profitable.

The sizable profits the two companies have enjoyed in recent quarters have led some investors to speculate that they could be spun off again as private firms.

But Republicans and Democrats in Congress, as well as President Obama, have all called for replacing Fannie Mae and Freddie Mac with a new housing finance system. The companies provide liquidity to the mortgage market by buying loans from lenders and repackaging them as securities that they offer investors with a guarantee.

“While I’m always glad when taxpayers see a return on investment, we can’t forget that Fannie and Freddie wouldn’t be earning one penny today without the government guaranteeing their transactions,” Sen. Bob Corker (R-Tenn.) said in a statement. “I don’t know of any other company in America that gets that kind of deal.”

Plans to replace Fannie Mae and Freddie Mac have emerged in both the Senate and the House of Representatives. A bipartisan Senate bill would ensure that a government backstop for the market remains in place in times of crisis, an approach favored by the Obama administration. A Republican bill in the House more sharply limits government mortgage guarantees.

Taking into account a decision to write up nearly $24 billion in tax-related assets, Freddie Mac’s net income was $30.5 billion for the period that ended Sept. 30. But even its pre-tax income of $6.5 billion, which compared with net income of $2.9 billion a year earlier, showed the company on solid footing.

“We’re a stronger and better-run company than we have been in years,” said Donald Layton, Freddie Mac’s chief executive. Freddie Mac has reported eight straight quarters of profitability.

Fannie Mae, which has posted seven straight quarterly profits, said rising home prices helped push its net income to $8.7 billion in the third quarter, up from $1.8 billion a year ago.

“We do expect annual earnings to remain strong for the foreseeable future,” Mayopoulos said. At the same time, he cautioned that future quarters may not be as profitable because of possible changes in home prices or interest rate fluctuations.

— Reuters