Circuit Court Judge James M. Rea has ordered Prince George's County jail officials to rehire 37 former guards fired after a 1980 strike, and to give them the pay, benefits and seniority they have lost since then.

County attorneys, who had argued that the strike was illegal, immediately requested and received a stay of execution on the order, pending an appeal to a three-judge panel. County Attorney Robert B. Ostrom said yesterday he would wait for a written memorandum from the judge before deciding what he will do next.

Guards at the County Detention Center in Upper Marlboro walked out for seven days in August 1980, triggering a three-hour rampage by jail inmates. The disturbance was quelled when police, sheriff's deputies and state troopers stormed the building's second floor and regained control.

"We could have had a wholesale slaughter," Corrections Department Director Arnette W. Gaston said at the time. "We could have had an Attica."

Rea also handled the judicial problems that resulted during the seven-day strike. He placed the jail under court control, ordered the striking guards back to work and rebuked then-County Executive Lawrence J. Hogan for failing to resolve the strike himself. He forbade the firing of the guards, as Hogan and Gaston had threatened to do.

A few days later, the Maryland Court of Special Appeals blocked Rea's order, and the following month Hogan fired the guards on the grounds that the strike was illegal. The firings were appealed to the county's personel board and were upheld.

On Wednesday, Rea ruled that the strike was, in fact, a legal one. Attorney Leonard R. Goldstein, who represents 31 of the fired guards, and six others who received fines and suspensions after the strike, said his clients are ready to go back to work.

"I'm very pleased with the way things have worked out," Goldstein said yesterday. "I think the judge's ruling is correct, and it vindicates not only the guards, but AFSCME the American Federation of State, County and Municipal Employees, which represented the guards at the time as well."

Until Rea granted the stay in the rehiring order, Goldstein said he was advising his clients to turn up for work at the jail the following morning. "Whether or not they can find things for them to do is a management problem," he said.

The jail hired 35 new guards last summer.