Lawyers, financial houses, accountants and others were paid more than $5 million in fees for their role in the Farmers Home Administration's sale last year of $2.9 billion worth of rural housing loans.

The fees were part of about $95 million in underwriting commissions, insurance and other costs incurred by the FmHA in its congressionally ordered effort to raise cash to help offset the federal budget deficit.

The largest fees went to the Bankers Trust Co., which got $1.8 million for trustee and custodian charges, and Brownstein, Zeidman & Schomer, a Washington law firm that received $825,000 as "counsel to the issuer" and $75,000 for preparing closing transcripts.

Although FmHA officials have praised the sale for exceeding its revenue target, the government took a heavy loss by selling the loans at a discount of about 54 percent. Net proceeds from the sale were $1.7 billion.

The loan sale was one of several that the government has carried out as a quick way of raising money to be applied to the deficit. FmHA also sold a package of rural water and sewer loans.

An FmHA report on the housing loan sale maintained that the government benefited by eliminating future liability for loan defaults and delinquencies. But it also noted conversely that the soundness of the loans that were sold enabled them to receive a top securities rating -- suggesting their potential for default was slight.

The report also claimed that FmHA and borrowers received nonmonetary benefits that included a streamlining of the agency's credit subsidy accounting system and a new opportunity for borrowers served by the private sector to set up escrow accounts for taxes and insurance.

Eric P. Thor, an FmHA associate administrator, said that the government's expenses were 0.3 percent of the gross receipts of $1.8 billion, which he described as "fairly reasonable."

An analysis of the expenses by Kidder, Peabody & Co., an adviser to FmHA on the sale, said the fees were "commensurate with those charged for similar transactions, particularly given the complexity and time constraints involved in this offering." The firm said the fee percentage was "consistent with industry standards."

The sale was ordered by Congress in its fiscal 1987 budget reconciliation and was designed by FmHA and housing groups to find unsubsidized rural housing loans that could be sold with ease. Loans held by borrowers thought to no longer need a federal subsidy because of higher income were put in the package.

But at least one participant, Robert Rapoza of the National Rural Housing Coalition, said his group now has misgivings about the sale. "We went along because the alternative was that Congress would cut the housing programs unless we found savings somewhere," he said. "But we didn't anticipate such a big discount and such big fees. This is a bad way to do business."

Other loan-sale expenses listed in the Kidder, Peabody analysis included $565,000 to Pandick Inc., for printing prospectuses; $420,000 to Arthur Andersen & Co. for accounting work; $380,000 to Salomon Brothers of New York as reimbursement for securities-filing fees; $374,000 to lawyers representing participating financial groups; $350,000 to the Manufacturers Hanover Agent Bank Services Corp. and $300,000 to Moody's Investors Service for certificate ratings.