Today, mortgage giant Fannie Mae announced it made a $10 billion profit this past spring. That's a remarkable turnaround considering the government had to bail out Fannie Mae, along with Freddie Mac, when the housing bubble burst five years ago. It's certainly good news for taxpayers. It's also good news for homebuyers who count on the two companies to back most of the country's home loans.

But not everyone's happy. Some investors in Fannie and Freddie are angry because they're not getting a share of the new profits. NPR's Chris Arnold reports.

CHRIS ARNOLD, BYLINE: The government bailed out a string of companies after the financial crisis -banks, automakers. But when it came to Fannie and Freddie, the terms of the bailout were different and quite harsh. Basically, Fannie and Freddie are stuck under the government's thumb with the U.S. Treasury taking all of their profits.

MATTHEW MCGILL: It's plainly illegal, and that's what matters.

ARNOLD: That's Matthew McGill, a lawyer for some of the investors who are suing the government.

MCGILL: The government never took that position with respect to General Motors or AIG or any of the many dozen banks that the Treasury bailed out in the midst of the financial crisis.

ARNOLD: Under the original terms of the bailout back in 2008, Fannie and Freddie were required to pay the Treasury a 10 percent annual dividend on their rescue money. But then home prices started rising, and Fannie and Freddie were becoming very profitable again. And that meant that the companies would be making more money every quarter than they were required to pay back to the government. So McGill says the Treasury and regulators last year...

MCGILL: They changed the terms from a 10 percent dividend to every dollar of profit the companies make ever.

ARNOLD: From the taxpayers' point of view, that might actually sound like a good thing because this move by the government insures that taxpayers get paid back before anybody else. But McGill says that after the bailout, investors bought Fannie and Freddie stock, or held on to it, and they based those decisions on the original language of the bailout. And he says by drastically changing the rules four years later, the government overstepped its legal authority.

MCGILL: The government pulled the rug out from under all investors when it changed the rules and seized for itself every dollar of profit Fannie and Freddie ever will earn.

ARNOLD: So here are the big overall numbers. In total, Fannie and Freddie took a combined $187 billion in bailout money. But estimates are that by next year, they'll have paid back that full amount. Still, under the terms of the bailout, all of those payments are like penalty fees or interest.

The whole deal is structured so that Fannie and Freddie could never get out of the government's control if Treasury didn't want to let them go. So even after they've paid back all of the money that they got in the first place through the bailout, they still just have to keep paying.

MCGILL: Just yesterday and today, Fannie and Freddie released their quarterly earnings which are a combined $15 billion in three months.

ARNOLD: Yeah, that's a lot of money.

MCGILL: It is. And the government takes it all.

ARNOLD: For its part, the Treasury Department said that it's not doing any interviews because of the pending litigation. But in a statement, a Treasury official said, quote, "We fully believe that our actions have been lawful and appropriate." And speaking at a recent conference, Treasury Secretary Jack Lew said this in response to a question about why the bailout is now structured the way it is.

SECRETARY JACK LEW: It was set up in a way to save our financial system, and it was set up in a way for taxpayers to get repaid. I think that it has worked.

ARNOLD: Critics of the lawsuit say that many of the plaintiffs are just hedge funds trying to siphon money out of Fannie and Freddie and the government. But the plaintiffs aren't all hedge funds. Steve Berman is a lawyer in another lawsuit against the Treasury.

STEVE BERMAN: One of our clients is a police officers' pension fund, thousands of pension funds invested in Freddie and Fannie.

ARNOLD: Berman, too, says that grabbing all the profits and giving the companies no way out amounts to an illegal taking by the government.

BERMAN: And the government just can't take people's property like that. That's what the Constitution provides you. If you take something, you have to compensate.

ARNOLD: Meanwhile, Fannie and Freddie making all this money, again, has caught the attention of legislators in Washington. Some are pushing for a bipartisan compromise on what to do with these two giant government-controlled companies that are still propping up the housing market. Chris Arnold, NPR News. Transcript provided by NPR, Copyright NPR.