Ten years ago, "the world's biggest savings and loan" was doing what savings and loans do best -- dying.

Saddled with tens of billions of dollars' worth of money-losing, low-rate mortgages and buying more every day, the Federal National Mortgage Association was rushing toward a collapse that could have been one of the most disastrous in modern history.

Not really a savings and loan, but with enough financial similarities to earn it that nickname, Fannie Mae had been set up to provide a reliable source of funds for the nation's housing markets. Allowing it to fail was unthinkable, but bailing it out would carry an awesome price tag.

But there was no crash. Nor was there a bailout. Instead, the huge company pulled off a spectacular turn-around, going from million-dollar-a-day losses in the early 1980s to a $1 billion profit last year.

On Thursday, the man widely credited with bringing about this reversal, David O. Maxwell, will retire as chairman and chief executive, leaving behind a highly developed financial empire capable, he believes, of prospering under almost any economic circumstances.

Fannie Mae's stock has ranged from a low of $2 a share when Maxwell took over in 1981 to a high of $47. Though the stock has slipped somewhat -- it closed at $38.375, up 37 1/2 cents Friday -- the firm is so solid that Maxwell said he thinks "it would take an event of such cataclysmic proportions as to result in a change of our form of government to put this company under."

Taking over the reins is James A. Johnson, 47, who had been vice chairman and who came to Fannie Mae from the Wall Street firm of Shearson Lehman Brothers Inc.

The tall, bespectacled Johnson is probably best known, however, as manager of Walter F. Mondale's 1984 presidential campaign.

And while Maxwell's challenge was formidable -- to rescue a company that was being swallowed by market forces -- Johnson's may in some ways be harder. He must satisfy stockholders who have grown used to rapid growth, while dealing with political forces that are likely to pull Fannie Mae in different and sometimes contradictory directions.

Johnson will preside over an enormous empire. Based in an outwardly modest brick building on upper Wisconsin Avenue NW in the District, Fannie Mae employs 1,500 people here and another 1,000 nationwide. It operates a sophisticated bond trading desk -- one of the biggest outside Wall Street -- buying and selling mortgage-backed securities to keep that market flowing and help its clients raise cash or acquire securities.

While some outsiders have looked at the size of the company and wondered if Johnson would be up to his new job -- whether he would be more than a political operative or possibly a pale imitation of Maxwell -- he has so far impressed market analysts, housing experts and Fannie Mae's own people.

Reserved and deliberate in style -- "he's definitely Mr. Control," said one staff member -- Johnson is seen by those around him as someone who thinks through questions and issues all the way to the end. At the same time, people who have dealt with him individually or in small groups have found him engaging and possessing an easy sense of humor.

"He has strong political acumen," said Warren Lasko of the Mortgage Bankers Association of America, a trade group based in Washington. "He seems to have solid knowledge of the mortgage business and he is savvy in the ways of Washington."

But Lasko added, "I do think the chairmanship {of Fannie Mae} is going to be more demanding in the decade future than the decade past."

On the market side, several housing experts noted, the buoyant growth of the 1980s is not likely to be repeated, making it difficult for Fannie Mae to match the rapid growth it has recorded in recent years.

On the government side, officials of the Bush administration, alarmed by the spreading crisis that has engulfed the savings and loan industry and now threatens banks, are floating various proposals meant to force Fannie Mae and other "government-sponsored enterprises" to strengthen their finances dramatically. Last year's housing bill mandates new legislation on the regulation and financing of these companies.

Government-sponsored enterprises, which include such disparate entities as the Student Loan Marketing Association (Sallie Mae) and the Farm Credit system, are private companies set up by the government to carry out certain public policy goals.

Fannie Mae and the Federal Home Loan Mortgage Corp. (Freddie Mac), its chief competitor, provide capital for the mortgage finance market. Sallie Mae makes a market in student loans.

The government connection allows them to borrow more cheaply than a purely private company could and those savings are supposedly passed on to home buyers, students, farmers and the like. The collapse and ensuing bailout of Farm Credit and the past problems at Fannie Mae, however, have caused many in government to fear that the implicit guarantee is too big a risk. Thus they are calling for much tighter capital requirements, which at their most extreme would be difficult for most of these entities to meet.

At the same time, some on Capitol Hill are wondering whether it might make sense to cap Fannie Mae's stockholder dividends and shift some of its profits to low-income housing. The profits and senior executive salaries -- Maxwell made $1.3 million in salary and bonuses in 1989 -- have made the company a tempting target.

The financial markets are quite clear in their view. They like Fannie Mae and want to see it left alone.

"They are the only financial services company that consistently produces results, where management tells you they are going to do this and then they go out and do it -- and in a very adverse operating environment," said Frank W. Anderson, an analyst with the Stephens Inc. investment firm in Little Rock, Ark.

Johnson's and Fannie Mae's "biggest challenge is political, to keep the politicians at bay, and make sure they realize the valuable service that Fannie Mae provides to the public," said David S. Penn, an analyst who follows the company for Legg Mason and Co. in Baltimore. "... If politicians do nothing, which is probably what they should do, in that sense, there's very little risk" to the company, he added.

On the housing side, though, there is concern that if earnings level off or slip, Fannie Mae and Freddie Mac -- Fannie Mae's only real competitor -- might raise lender fees and other costs, driving up mortgage costs.

Maxwell and Johnson express confidence that they can satisfy the concerns of regulators as to the company's safety and soundness, while continuing to keep housing finance costs down and seeking ways to help low-income people and the elderly.

Both said they doubted that Congress would ultimately act in any way that would damage Fannie Mae, particularly when the nation's financial system is in turmoil. Indeed, said Johnson, one of the firm's main "challenges is to continue to be a solid rock in the middle of the mortgage finance system."

Becoming that "solid rock" hasn't been easy.

Spun off from the government in 1968 with a mandate to provide funds for housing, Fannie Mae began its life as a private company doing business much like a savings and loan.

It raised money by borrowing and using the money to buy mortgages from lenders such as savings and loans, mortgage bankers and commercial banks.

With its government connection and by issuing short-term debt, the company was able to borrow at low interest rates. The rates on the mortgages it owned being higher, the company was able to make a comfortable profit on this difference, or "spread."

But when interest rates rose and its short-term debt had to be renewed, Fannie Mae could no longer borrow at rates below those on its mortgages. Red ink flowed as a result.

The company also had a policy of deciding on an acceptable interest rate for loans it would buy, and then issue loan-buying commitments that were good for as much as a year.

This meant that a lender could agree to such a deal and then wait to see what interest rates did. If they declined, the lender kept the loan, which would be profitable. It they rose, placing the loan "under water," the lender would sell it to Fannie Mae. Thus, Fannie Mae was not only losing money on its old loans, it was losing money on its new ones as well.

The company "was doing business as a private sector concern the same way it had {when it was} part of the government," Maxwell recalled.

The first step when Maxwell took over from Oakley Hunter in 1981 was to revamp this commitment system. Commitment times were shortened, fees paid by the lenders for the service were raised, and lenders who "took down" a Fannie Mae commitment were obligated to deliver the loans.

That meant that Fannie Mae could begin to do the essential thing -- match the terms on the money it borrowed with the terms on the loans it bought, said Timothy Howard, the company's chief financial officer.

This isn't easy under any circumstances, but any lender that does not do it risks getting killed by interest rate increases. The reason is simple. If I borrow a dollar from you for five years at 5 percent a year and then lend that dollar to my friend for 30 years at 8 percent, I have locked in a three-point "positive spread." My friend pays me 8 cents a year in interest for the dollar while I pay you only a nickel.

But at the end of the five years what happens? I must repay you and re-borrow the dollar somewhere. If rates have risen to 11 percent, for instance, that's what I must pay and now I have a negative spread.

This, on a grand scale, is what was happening to Fannie Mae. It was borrowing vast sums on Wall Street, much of it for terms considerably shorter than its mortgages. In addition, Fannie Mae had no way of knowing when the mortgages it owned would be repaid. Some were paid off in a few years because the homeowner sold the house or because rates declined and the borrower refinanced. Some remained on the books the entire 30 years.

Today Fannie Mae has a vast array of computers and software designed to simulate all sorts of economic conditions and calculate the terms necessary to ensure a profitable spread. As a result, Howard said, the company can all but guarantee that no loan it buys will ever be "under water."

The spread on its huge portfolio -- including more than $116 billion worth of mortgages -- is about 1.4 percent, a major factor in its healthy bottom line.

Fannie Mae also has helped create a vast market in mortgage-backed securities. Here, it buys large numbers of mortgages and pools them and sells interests in the pool. Investors get a share of the repayments of the principal and interest as they come in while Fannie Mae gets a steady stream of fee income and bears no interest rate risk.

In return for the fees, Fannie Mae guarantees that the investors will get their money, so if a borrower defaults, Fannie Mae must make good. But with tighter credit standards for borrowers in recent years, Fannie Mae has kept defaults low even in the deteriorating real estate market.

Maxwell and Johnson said they believe this sound financial performance puts the company in an excellent position to fend off unwise political interference. Both said they endorse the idea of improving the company's capital position and that they understand regulators' concerns.

"My belief is that Fannie Mae has a bright future" and is in a good position to deal with these issues, Johnson said.

Said Maxwell: "Fannie Mae really works. ... We are really delivering on what we were set up to do."