ATLANTA, DEC. 4 (FRIDAY) -- Cuban inmates at the federal penitentiary here signed an agreement early this morning to end their 11-day takeover and immediately released their remaining 89 hostages, several hours after federal negotiators had offered them "new language."

After an almost festive afternoon, in which scores of inmates gathered on the hospital roof to celebrate the agreement with cheers and salsa music broadcast over a loudspeaker, the signing ceremony finally began at 12:52 a.m.

It ended jubilantly at 1:02 a.m., in applause, embraces and backslaps. The departing hostages walked briskly through a double line of inmate and federal negotiators, shaking their hands.

The eight-point agreement ended the second of two uprisings in which Cuban inmates protested a revived U.S. pact with Cuba to deport about 2,500 refugees who arrived here in the 1980 Mariel boatlifts. Inmates at the Federal Detention Center in Oakdale, La., surrendered Sunday, nine days after taking 28 hostages there.

The Oakdale inmates signed an accord after hearing a videotaped appeal from Auxiliary Bishop Agustin A. Roman of Miami. Roman, a Cuban exile, was the first person to sign the document here tonight, praying with closed eyes as its terms were read aloud.

The agreement, which is more specific than the Oakdale accord and will apply to the Oakdale inmates, provides for a moratorium on deportation of 3,806 Mariel Cubans being detained nationwide after finishing criminal sentences. It provides for hearings by June 30, 1988, and would allow those who are denied U.S. residence to apply for acceptance by a third country rather than return to Cuba.

Attorney General Edwin Meese III, who approved the agreement last week offered a moratorium on deportations of Marielitos and a review of each inmate's immigration status if the inmates surrendered without hurting their hostages.

Four hostages were released early Sunday morning in an apparent goodwill gesture. A fifth was released Tuesday night, partly in honor of the 29th birthday of Carla Dudeck, director of the Coalition to Support Cuban Detainees. When Dudeck was summoned into the prison moments after midnight, it was a signal to those outside that the others were about to be freed.

Steven Donziger, a coalition member, said he saw little gain for the Cubans in the agreement because it did not address their rights during the review process or guarantee that they would not be deported.

The signing took place in the prison dining area, a neutral zone where face-to-face negotiations had taken place during the siege. Justice Department spokesman Thomas M. Stewart said the ceremony was delayed in part for the arrival from Miami of Roman, whose presence the inmates had requested.

Roman was flown here Thursday night aboard a U.S. Customs Service plane, telling reporters at the airport that he was here to "pray with my brothers and to receive all of the hostages." A helicopter brought him to the prison shortly before 10:30 p.m.

Justice Department spokesman Patrick S. Korten said the six inmate negotiators met with federal officials shortly before noon Thursday to hear "clarifications" of the revised government offer, then met for two more hours with the rest of the inmates.

"At about 4 p.m., they called to tell us that the agreement had been accepted," Korten said.

Earlier, however, the inmates on the roof upstaged the federal information network again by announcing over their loudspeaker -- now called Radio Mariel for the Cuban port from which most of them set out -- that they had approved the agreement.

They said it would be signed in early evening.

"The suffering of everybody is over," a voice on the loudspeaker said as the inmates jumped up and down and waved to their families gathered in parking lots across the street.

Charlie Marrero Gonzalez, one of the chief inmate negotiators, said they had a fight on their hands persuading their fellow inmates to accept the agreement. Marrero, a prisoner for eight years, said they treated the hostages well because we wanted to show the world we are not the assassins we have been portrayed as being.

"We treated all the hostages like family," he said.

Gary McCune, regional director of prisons, said this morning that he had greeted all the former hostages, and they "seemed to be in good health -- every one." Most of them are prison guards.

Weldon Kennedy, FBI agent in charge of the Atlanta field office, said about 200 inmates were holding out this morning. But he said he believed they would be persuaded to participate in the agreement.

A total of 1,105 Cuban inmates remained this morning of the nearly 1,400 at the prison when the uprising began. Nearly 300 surrendered before the siege ended and were transferred to other federal facilities.

Kennedy said federal officials would begin processing the remaining inmates at noon today, inviting them to come, one by one and unarmed, to a central location. He expects all the transfers to take 24 hours.

Korten said the inmates' negotiators and federal officials met Thursday from about 11:40 to 1:30 p.m. Asked whether the government had made new compromises with the inmates, Korten replied, "Of course."

"At this session, the government clarified its position on a number of points and offered new language designed to meet some of the concerns expressed earlier by the negotiators for the detainees," he said. "At the conclusion of this session, all of the negotiators for the detainees initialed a document, indicating their agreement on all points of a settlement that would bring a conclusion to this incident."

The inmate negotiators then caucused for two hours with the rest of the detainees and called federal officials to confirm their approval.

Korten said Meese approved the final agreement. The agreement reached here will apply to the Oakdale inmates, who were promised no deportations without individual reviews and no reprisals for damage to the detention center, Korten said.

The sudden agreement came as a surprise after a day in which the mood ranged from optimism to pessimism to boredom. Korten's initial announcement of the tentative agreement, shortly after 3 p.m., came only five hours after he had strongly chided the news media for saying that an agreement was imminent.

"For those of you who have been attaching a great deal of significance to steps we have taken to set up a pool coverage arrangement inside the prison, cut it out," he said. " . . . We have no reason at this time to believe that a settlement is imminent."

The government stepped up what amounted to psychological warfare against the detainees early in the morning. Loudly thumping Huey helicopters were sent over inmate-occupied sections of the prison in an effort to make the inmates nervous, a tactic that had been used in Oakdale. The flights stopped during the two hours in which, it was learned later, the negotiators were meeting.

Late Thursday afternoon, several dozen Cuban detainees stood on the prison-hospital roof. U.S. and Cuban flags fluttered from the same standard. They displayed a hand-painted sign that said, "We are not communists. We do not accept deportation to Cuba."

At about 9 p.m., as the wait lengthened, about 300 people, led by the Rev. Joseph Lowry of the Southern Christian Leadership Conference, marched up the street singing, "We Shall Overcome" and stopped in front of the prison for a prayer service as the inmates looked on from the roof.

The marchers carried a large sign saying, "Pray for hostages, detainees, families, negotiators."