More Americans are buying homes. Home prices are rising at the fastest rate since the housing bubble burst. Banks are lending only to the most qualified buyers. And fewer homes are falling into foreclosure.

All of that is a boon to Fannie Mae and its smaller sibling Freddie Mac, which own or guarantee half of all US mortgages and back nearly 90 percent of new ones. When people buy homes and nearly all pay their mortgage bills, Fannie and Freddie cannot help but make piles of money.

And it is a big reason Fannie decided the time was right this year to capitalize on the tax benefits of the bad loans it absorbed during the crisis.

On Thursday, Fannie said that it applied tax credits it had saved from its losses on delinquent loans suffered during the crisis to its first-quarter earnings. By applying those credits to its 2013 taxes, Fannie reduced what it owed the government and boosted its profit.

The result: Fannie made more money from January through March than it had in any other quarter. Of the $58.7 billion earned, nearly $51 billion came in part from using the tax credits. That followed $17.2 billion in profit earned last year. And Fannie says it expects to stay profitable for ‘‘the foreseeable future.’’

Nearly all of that money is going back to the government, which rescued Fannie Mae and Freddie Mac in the 2008 financial crisis.