NEW YORK (Fortune) -- They own or guarantee $5 trillion worth of mortgages� - nearly half of all the country's outstanding home loan debt - and they're crashing. But not everybody is convinced they should be.

Fannie Mae and Freddie Mac are struggling with an investor loss of confidence so great that, while they're unlikely to go under, they could conceivably see their ability to function impaired. That would wreak yet more havoc on an already wrecked housing market - making loans tougher to come by and possibly pushing hundreds of billions of dollars in cost onto U.S. taxpayers.

The extent of their troubles is in debate. Several analysts and a former Federal Reserve governor have said the two companies desperately need to raise money to continue their business of buying and guaranteeing home mortgages.

Others, including Fannie and Freddie, their regulators, some Wall Street analysts, and Sen. Christopher Dodd, D - Conn., the chairman of the Senate Banking Committee, have defended the strength of the two companies.

"What's important are facts - and the facts are that Fannie and Freddie are in sound situation," Dodd said on CNN's Late Edition on Sunday. "They have more than adequate capital. They're in good shape. The chairman of the Federal Reserve has said as much. The Secretary of the Treasury has said as much."

The Treasury Dept. and the Federal Reserve on Sunday outlined plans that would provide capital to Fannie and Freddie if it were needed.

Still, inherent problems

How could the companies end up in such awful straits? Given the way they were created and run, a better question might be: how could they not?

The two companies are so-called government-sponsored enterprises, created by Congress in 1938 (Fannie) and 1970 (Freddie) to help more Americans buy houses.

Their mandate is to maintain a market for mortgages - buying loans from banks, repackaging them as bonds, and selling those securities to investors with a guarantee that they will be paid.

This makes lending more tempting for banks because Fannie and Freddie take on risks like missed payments, defaults and swings in interest rates.

But the companies are also publicly traded, with the usual mandate of trying to maximize profits for shareholders.

That effort, of course, involves risk, but as quasi-government programs, they've long carried an implicit guarantee that the feds wouldn't let them fail.

Their hybrid nature created both the opportunity and the temptation for the enterprises to take on more risk and to make themselves ever larger, more important and thus more profitable players in the mortgage market.

Very special treatment

The market and ratings agencies have treated Fannie and Freddie as bulletproof, even though the actual business of dealing with interest sensitive loans is very risky. This is in large part because of the very special perks granted to the mortgage giants, but to no one else.

Each may borrow up to $2.25 billion direct from the Treasury. They are exempt from state and local income taxes and from Securities and Exchange Commission registration requirements and fees. And they can use the Federal Reserve as their bank.

One result of all this special treatment was AAA credit ratings. That means Fannie and Freddie could borrow at super-low rates, a benefit they used to purchase - and hold -high-yielding mortgage loans. The spread between the two provided an irresistible earnings stream and the companies just kept getting bigger.

The mortgages they hold on their books alone total about $1.4 trillion, said Mike Stathis, managing Principal of Apex Venture Advisors, a research and advisory firm.

In the meantime, the companies were allowed to operate in this manner, piling on risk after risk, with virtually no capital cushion (Wall Street speak for the rainy-day piggybank financial companies keep should one of their investments blow up.) As the company's loan portfolio loses value and the mortgage market continues to crumble, it's easy to see why this was a fatal misstep.

Some saw the crisis coming before this week. For example, Alan Greenspan famously warned in 2004 that Fannie and Freddie's rapid growth needed to be curbed because their expansion threatened the financial markets.

Still, the cocktail of high credit ratings, domination of the mortgage securities market, and preferential government treatment led to the sort of shenanigans that go hand in hand with excessive privilege.

Fannie overstated its earnings by $10.6 billion from 1998 through 2004, and its chief executive Franklin Raines lost his job. Freddie Mac had understated its profit by nearly $5 billion from 2000 through 2002. Both companies missed earnings filings while they overhauled their books.

"If Fannie and Freddie had been created in the private sector, they wouldn't look like this," says Christopher Whalen, head of research firm Institutional Risk Analytics. "They have a public sector mission to expand housing and run what is essentially an insurance company. But they also have a conduit to securitize and sell loans, which is what broker-dealers like Lehman do; and they have an interest arbitrage piece (making money on the spread between interest rates) that looks like a hedge fund."

Robert Rodriguez, the founder of First Pacific Advisors, hasn't bought Fannie for Freddie bonds for over two years. "With the recent issuance of their financials, we were still uncomfortable with their leverage," Rodriguez says. "We believed there was considerable balance sheet risk in both of these companies.

Now the dwindling pool of mortgages, higher foreclosure risk, and a shaky interest rate environment have the companies on the ropes; and investors are beginning to lose faith in Fannie and Freddie.

Both firms told Fortune that they have enough capital to weather the storm and continue to support the nation's housing market.

And yet, Fannie has fallen 32% this week and 65% since the beginning of the year. Freddie plunged 47% so far this week and is down 75% since January.

Investors have lost faith that the companies can operate in their current incarnation without running into major problems.

If investors abandon these companies, what do we learn from this odd Frankenstein of a business model?

"Nobody ever believed that Fannie and Freddie were truly private and they never should have been," says Whalen. "Now we will all have to pay for a company that has gone astray."