U.S. taxpayers have recouped all of the $187 billion they gave mortgage giants Fannie Mae and Freddie Mac in one of the most expensive bailouts of the financial crisis.

The milestone was reached after Fannie Mae reported Friday it will pay Treasury an additional $7 billion in profit from the end of last year.

Beginning in late 2008, the federal government bailed out the two firms that had become nearly the only source of loans for American home owners. With the payment announced Friday, the payments from the two firms now comes to $192 billion.

The bursting of the housing bubble in 2006 and the jump in foreclosures that followed caused massive losses for Fannie and Freddie, each of which buys home loans from lenders, bundles them up, and sells them to investors with a guarantee the loans will be repaid.

Related: Home prices show signs of topping out

When the federal government took control of Fannie and Freddie in September 2008, it received preferred stock in the companies in return for the bailout funds.

Through 2012, they were each paying the U.S. Treasury a dividend. Starting in 2013, the government started essentially collecting all of each firm's profits.

The payments to taxpayers are treated as dividends and will continue for now.

The only things that could stop the payments would be a new housing downturn that plunges Fannie and Freddie back into red ink; passage of one of the legislative proposals to phase out the two firms; or a successful legal challenge to the current payment system.

Private investors that still own 20% of Fannie and Freddie have filed a federal lawsuit opposing the current payment system.

Related: Five years later, are we ready for the next meltdown?

Freddie has already made dividend payments essentially matching the $71.3 billion it received in the bailout. It is due to report results next week, and is expected to post additional profit and payments to Treasury.

Fannie and Freddie are not the only firms that were bailed out that payed back more than they received.

Taxpayers also made a $22.7 billion profit on the bailout of insurer AIG (AIG). The TARP bailout fund also received about $22 billion more than it gave to the nation's banks, with the biggest profit in the banking bailout coming from Treasury's sale of Citigroup (C) shares.

Taxpayers came up about $10 billion short on its bailout of General Motors (GM) when Treasury sold its remaining shares in the automaker last December.

It had an additional $1.3 billion shortfall on the Chrysler Group bailout.

And the final accounting for its bailout of the former GMAC, now known as Ally Financial, has yet to be determined and could still result in a loss to taxpayers.

Fannie's fourth-quarter profit caps its most profitable year on record, earning $84 billion during 2013. A combination of a housing market recovery, with a drop in foreclosures, rising home prices and a rebound in home sales all helped to improve the company's bottom line.