A federal bankruptcy judge approved the sale last night of Greater Southeast Community Hospital to an Arizona firm, rescuing the only full-service hospital east of the Anacostia River from immediate shutdown.

U.S. Bankruptcy Judge S. Martin Teel Jr. marched a legion of attorneys through four grueling days of negotiations and hearings until he was satisfied with the complex agreement they produced.

The courtroom erupted in loud and sustained applause when yesterday's session ended about 6:45 p.m. Community activists, lawyers, clients and consultants celebrated not only the rescue of the hospital and its 1,100 jobs, but the resumption of interrupted lives.

"What can I say? I'm relieved," said hospital attorney David E. Rice, who has navigated the case since the hospital filed for bankruptcy protection in May.

"I'm ecstatic," said George E. Gilbert, a physician and chief executive of Greater Southeast, who has led the hospital since it fell into financial crisis in 1998.

"This was an absolutely necessary step for the community," said Francis McLoughlin Jr., who represented a coalition of D.C. residents formed a few weeks ago when it became apparent that the chances of a court-ordered liquidation had grown. "The city and all the parties came through."

An X-ray technician, Phil Coley, who was reached last night at the hospital said, "I don't know all the details, but we are just glad that the hospital was saved."

"We are doing a lot better today," said Vernice Duncan, an administrative nurse supervisor. She said other nurses were ecstatic.

If the transaction is consummated--which is expected to take about two months--a small Arizona-based hospital chain, Doctor's Community Healthcare Corp., will buy the 280-bed hospital for about $22 million. That price includes a $3.5 million loan to Greater Southeast to keep it operating until the sale conditions are met and the documents are signed. The hospital owes its creditors $70 million.

The agreement provides for the hospital's top creditor, Daiwa Bank of Japan, to receive $9.35 million. Mutual fund companies and other holders of $45 million worth of municipal bonds issued by the hospital in 1993, along with other creditors and many of the attorneys in the case, will divide the balance of the sale price.

Doctors Community Chief Executive Officer Paul R. Tuft said by telephone from Scottsdale, Ariz., last night that he was celebrating the judge's decision and that the staff physicians and community representatives would have a greater say in the hospital's operation. He said he was worn out by the negotiations, which he attended until yesterday.

"It certainly reminded me of roller derby," he said. "I've never seen anything like it."

So many lawyers participated in the case that total legal fees during the hearings approached $100,000 a day, attorneys said.

On Wednesday, with the hospital's cash reserves gone and payday looming, the scene assumed the appearance of a legal bazaar as lawyers huddled in ever-changing groups in the courthouse's marble hallways, bargaining over division of the assets.

Negotiations and hearings continued until evening and then resumed for a full day on the Veterans Day holiday in an otherwise deserted courthouse.

Sessions continued another 12 hours on Friday, with lawyers arguing that liquidating the hospital--the only alternative to the selling it-- would never generate as much money for creditors.

"It reminds me of 'Let's Make a Deal,' " said Daiwa attorney Peter D. Isakoff. "You've got the $21 million in your hand versus what's behind the curtain."

It became apparent Friday night that the sale had enough support from creditors for approval. But Teel stunned the courtroom when he raised new concerns and sent the parties back for more talks.

Many lawyers interpreted his objections as disapproval of the amount of money the deal would have given Daiwa at the expense of the bond holders, which include mutual fund operators Eaton Vance and Salomon Smith Barney.

Negotiations continued until 1:20 a.m. yesterday, when exhausted creditors agreed to provide another $140,000 to keep the hospital operating through the remainder of the day. The judge ordered everyone to return at 11 a.m.

Many lawyers took the position that Daiwa would have to yield some of the $11 million it would have gotten under the proposed sale and direct more to the bond holders. At mid-afternoon yesterday, Teel appeared in his courtroom for only a few minutes after hours of hallway negotiations.

He was told a deal had not been reached, and that the D.C. financial control board's attorney, Thomas J. Catliota , had begun shuttle diplomacy among the creditors.

"I'm confident and hopeful and would ask the court's continued indulgence to let this process run itself out. We have an intra-creditor money issue," said Catliota. "There's too much at stake to let something as silly as money get in the way of this deal."

By the end of the process, Catliota was credited with brokering a set of provisions--of seemingly mind-numbing complexity--that extracted concessions from virtually every party at the table and satisfied the judge. In the judge's chambers before the final hearing, the lawyers gave him an ovation.

"He really was phenomenal," said Deryck A. Palmer, one of Daiwa's attorneys. "He kept the process moving forward. He should get all the credit for saving the hospital."

Staff writer Emily Wax contributed to this report.

CAPTION: Virgil C. McDonald, chairman of the board of Greater Southeast Hospital, talks with reporters after the sale was approved.