The Federal Housing Administration is getting a bum rap. The agency, which currently accounts for almost a third of all mortgages received by U.S. home buyers, has done an admirable job during the six-year housing crash. Although the FHA does need to reduce its role in the mortgage market eventually, this must be done judiciously. Private mortgage lending won’t revive until the government pulls back. But if that happens too quickly, private lending will remain dormant, undermining the still fragile housing market and economy.

It has become fashionable to rail against government intervention in the economy, and the FHA is a favorite example by those trying to show the government’s overreach. In reality, the FHA shows how government action during the Great Recession forestalled a much worse economic fate. If FHA lending had not expanded after private mortgage lending collapsed, the housing market would have cratered, taking the economy with it.

Until a few years ago, the FHA was just a bit player in the mortgage market. During the mid-2000s housing bubble, the agency made only one of every 25 U.S. mortgage loans. The types of loans that were all the rage then — subprime, alt-A and option ARMs among them — came from a wide array of private mortgage lenders and were packaged by investment banks into securities that were then sold to global investors.

The FHA couldn’t compete with private lenders offering no-down-payment loans to borrowers with very low credit scores and little, if any, income documentation. Many of these loans sported exceptionally low initial interest rates, which generally adjusted two years after origination, and even allowed borrowers to defer payments, adding them into the mortgage balance.

Regulators did little to control the bad mortgage lending. Some of the most egregious practices were associated with nonbank lenders who didn’t answer to regulators. Moreover, the multiplicity of agencies overseeing the mortgage market made it hard to reach consensus on rules and guidance. And the nation’s most important financial regulator — the Federal Reserve — held a philosophical disregard for mortgage market regulation. Top Fed officials believed global investors knew what they were doing: If they were willing to buy mortgage securities, those securities must be sound.

They clearly were not. Millions of private mortgage loans made during the housing boom subsequently defaulted as housing prices fell. Hundreds of billions of dollars were lost, undermining the global financial system and causing private mortgage lending to collapse. Since then, private mortgage loans have been made only to households with high-paying jobs, lofty credit scores and the ability to make large down payments.

The FHA stepped into this breach. The volume of loans backed by the agency has more than tripled during the past four years, to over $1 trillion. Without this rapid expansion in FHA lending, a credit crunch would have wiped out the housing market. As it is, U.S. home prices have fallen by more than a third; without the FHA, the decline would have been substantially worse. Many more homes would have been foreclosed, and private financial institutions would have faced measurably greater losses. Aggressive intervention by the FHA saved the housing market and the economy from a much darker fate.

Indeed, the FHA was born out of the Great Depression, which was also caused in significant part by a foreclosure crisis. Mortgages in the early 1930s were mostly three- to five-year “bullet” loans, which did not amortize and were due in full at maturity. This wasn’t a problem if credit was ample, as maturing loans could be easily rolled over; but when panicked depositors pulled their money out of the banks, millions of households lost homes.

The FHA introduced the 30-year fixed-rate mortgage to shelter homeowners from the business cycle. This attracted Depression-scarred households back to the housing market, helping raise the homeownership rate from 40 percent in the 1930s to 65 percent by the 1980s (see chart). The agency also nudged private lenders to comply with fair housing and equal access laws to end discrimination in mortgage lending. And the FHA stood as a ready source of mortgages if the private sector were to ever fall down again. It did in the Great Recession, and the FHA stepped up.

Like any financial institution involved with housing over the past few years, the FHA’s finances have been shredded. But unlike many others, it is still standing. The agency’s capital reserves — its cushion against losses — have been mostly, but not entirely, depleted. If the economy continues to recover, these reserves can be rebuilt over time. Yet it is possible that house prices will fall further, mortgage losses will mount, and the FHA will need financial help from taxpayers. If so, it will be the first time in its nearly 80-year history that the FHA is unable to fund itself. That would be a pity, but well worth the cost, as the FHA has saved taxpayers a bundle over the decades.

This does not mean the FHA should continue to dominate the U.S. mortgage market. The agency itself appears uncomfortable with its outsized role, and has taken appropriate steps to lower its profile by raising the insurance premiums it charges borrowers and tightening its lending standards. The average credit score of today’s FHA borrowers is higher than the average American household with a score. As it becomes more costly and difficult to get a FHA loan, loans from private mortgage lenders will become more attractive and their market share will grow.

Yet although the FHA needs to continue moving in this direction, it must be careful not to move too quickly. Higher mortgage rates while private credit is still scarce could short-circuit a recovery in the housing market. Policymakers’ recent decision to increase the size of mortgages the FHA can make for one more year makes sense in this context.

The FHA’s success provides strong evidence that government can and should play a role in the nation’s mortgage finance system. It also demonstrates that although government intervention in the economy during the Great Recession was messy, things would have been a lot messier without it.

Mark Zandi is chief economist of Moody’s Analytics, a subsidiary of Moody’s Corp. He is the author of “Financial Shock,” an exposé of the financial crisis. His column will appear regularly.