As Maryland officials stood in a Rockville courtroom shortly after 11 p.m. Thursday, waiting for a judge to place Bethesda-based Community Savings & Loan and its EPIC real estate subsidiary into conservatorship, they firmly believed they were gaining control over the troubled entities. But what they didn't know was that lawyers for EPIC officials had been in another courtroom in Alexandria for three hours foiling the state's efforts by quietly placing their 341 limited partnerships under the protection of federal bankruptcy laws.

The bankruptcy filings caught Maryland officials totally by surprise, snatching from them most of the assets they hoped to control through the conservatorship and leaving the state facing an undetermined period of legal wrangling.

The partnerships own more than 20,000 single-family homes, which EPIC values at $1.5 billion, and rental income from them is by far the largest source of income to the EPIC companies.

"The effect of the bankruptcy filing is to stay legal proceedings against the partnerships," EPIC said in a statement yesterday. It termed the filings necessary to "protect the depositors and creditors of Community Savings and the investor participants in EPIC's limited partnership programs."

Officials of EPIC, the state, and holders of mortgages on which the partnerships are in default agreed that leaves EPIC with far more control of its holdings than conservatorship would have.

"Our fear -- our major concern -- is the ultimate status of Community: will Community have to stand in line behind creditors?" said a senior official in the administration of Maryland Gov. Harry Hughes.

State officials said they are now examining their options, including the possibility of asking the bankruptcy court to dismiss the EPIC petition. However, in bankruptcies much simpler than EPIC's, the courts have taken six months or more before granting a dismissal.

The state officials said they had been aware that bankruptcy was a possibility, but had not realized that they were in a race to the courthouse.

EPIC's officials were also aware that the state was planning to ask to take the company under control. According to one former EPIC employe, company officials told several associates in a meeting on Thursday that they anticipated the state might take control through conservatorship -- an action they deemed "undesirable" -- and they expected they would have to move to thwart that attempt within 36 hours.

Montgomery County Circuit Court Judge Irma S. Raker said she was notified by the state at 4:25 p.m. Thursday of the impending petition for conservatorship. She convened a hearing around 9 p.m. and signed the order at 11:10 p.m. writing the time on it in longhand at the request of Community, which had not fought the conservatorship in court. Much of the delay before the signing was caused by proceural discussions and a slow Xerox machine that had to churn out several copies of the order.

Only three hours before that order was finally signed, EPIC representatives had appeared at the bankruptcy court in Alexandria and begun filing their papers. The time was crucial because when Raker's order was signed it placed the state in charge of EPIC and EPIC officials then would have lacked authority to file the bankruptcy petitions.

The petitions covered only the partnerships. No EPIC-related corporations were placed in bankruptcy. The 341 filings were identical except for the names of the partnerships, and consisted of minimal information with no listing of assets or liabilities of the entities.

Community President Clayton C. McCuistion said the bankruptcy filings were necessary in order for EPIC, as the general partner of each of the partnerships, "to protect the limited partners' interests."

"There are a lot of interests. One reason for opting for bankruptcy was to make sure those interests were all looked after," he said. He made it plain that EPIC feared that the state might sacrifice the interests of others involved in the case if that would benefit Community.

EPIC's partnerships have outstanding mortgages of more than $1.3 billion. In mid-August, EPIC announced that it was delinquent on payments due on some of this debt and it was possible there would be a default. That announcement touched off a run on Community, forcing Hughes to ban withdrawals from the institution for 20 days. That ban was to expire Sunday night. Under the conservatorship, it is now extended for at least another 45 days.

With the collapse of the private insurance program covering some state thrifts, the state has guaranteed deposits in those institutions until they can obtain federal deposit insurance.

But Frederick L. Dewberry, acting director of the Maryland Deposit Insurance Fund, said Community "had enountered major problems" in its insurance application, and that it did not appear that the institution would be able to solve them.

Under legislation approved in May, institutions with more than $40 million in assets must obtain federal coverage by the end of the year. If they do not do so, the law mandates that they be liquidated or merged with a stronger institution.

In addition to the problems that it has caused for Community, the huge default is sending shock waves through the mortgage finance industry. EPIC's loans carried private mortgage insurance, and a wholesale default would leave the private mortgage insurance industry facing $300 million to $400 million in potential claims.

EPIC either sold its loans outright, or sold securities backed by them. The owners of the loans and securities, which include other savings and loan institutions that can ill afford to have them go bad, are anxious to see properties foreclosed and sold if EPIC cannot be bailed out.

Sources in the mortgage insurance industry said that since the loans are insured, the mortgage holders want to go ahead with foreclosure and then file claims with the insurers. That could seriously damage the insurers and very likely leave unsecured creditors with nothing.

The insurers, on the other hand, gain a measure of protection from the bankruptcy filings, since no claims can be filed against them until the bankruptcy issue is resolved.

Thursday night's court activity climaxed three weeks of frantic negotiating on several fronts. While EPIC and the mortgage insurers, assisted by Dean Witter Reynolds and other Wall Street investment bankers, sought to work out a rescue plan, the state nervously looked for ways to keep Community from re-igniting the savings and loan crisis.

"We were aware that the Federal Home Loan Bank Board had severe questions about the EPIC subsidiaries but when the press reported the delinquencies -- and the attendant runs -- we took a closer look," said Benjamin Bialek, Hughes' chief legal adviser.

Bialek said that in the days following the widespread runs on Community over the weekend of Aug. 17, Hughes met in his State House office with people from Salomon Brothers, the giant New York investment banking firm, and with mortgage insurance company representatives to begin assessing the damage to the thrift and the gravity of the EPIC delinquincies.

In that same week, the trustees for those holding EPIC mortgage securities met in Hughes' Baltimore office to discuss a possible suit to force payment of principal and interest that was due in August. Those talks "went nowhere" towards improving either Community's or EPIC's position, Bialek said.

Also during this period, Hughes' staff and Dewberry contracted with the Federal Reserve Board to have federal banking examiners review Community's books. Until that happened, Bialek said, "we didn't have an accurate picture" of Community's balance sheet.

On Monday, Aug. 26, state officials, led by Bruce McPherson, a private consultant to Dewberry, also entered Community, Bialek said.

Bialek said the administration's main concern prior to the conservatorship was preserving Community -- or as much of its assets and deposits as was possible. The task was complicated because "the mort-gage insurers, the lenders, the certificate holders of mortgage-backed securities all had interests different from that of Community," Bialek said. "They're much more concerned about their exposure on EPIC" loans.

Similarly, Bialek and other state officials "always viewed solving the EPIC problem and solving Community's problems as 100 percent interrelated," he said. But he added: "If an acceptable solution was not found among the private parties, the state would have to step in and make sure Community was not left behind."

With no corporate savior in sight for EPIC, the key state officials met last Friday afternoon in Baltimore and drafted the court documents needed to place the thrift in conservatorship, Bialek said. The state's only other option for preserving what it could of Community was to extend Hughes' freeze on deposits, an alternative rejected as temporary and unsatisfactory, Bialek said.

Two days ago, with momentum for conservatorship growing and time running out on Hughes' earlier deposit freeze, Dean Witter Reynolds officials and EPIC mortgage insurers met in New York and conferred by telephone with Bialek, Dewberry, Hughes' staff chief and Maryland's top fiscal planner. The discussion in that conference call showed once and for all that no "white knight" would ride to Community's rescue, Bialek said.

"The thrift's liquidity hadn't improved and we had no reason to believe it would," one state official said.

Bialek and other key officials said they chose conservatorship for Community because it should enable them to ensure that the thrift's assets are preserved and no funds are diverted. It also places the state in a strong position to control Community in the aftermath of multimillion-dollar legal actions against the thrift.