Two U.S.-judges in Maryland yesterday ordered state officials to remove-1,000 inmates in the next eight months from the overcrowded Maryland Penitentiary and the Maryland House of Correction.

Maryland Attorney General Francis (Bill) Burch said that meeting the deadline will pose "a substantial threat to public safety."

The state has asked for 22 months to reduce the populations at the maximum-security penitentiary in Baltimore and the medium-security House of Correction in Jessup.

"When we asked for 22 months, we were not bargaining." Acting Gov. Blair Lee III said recently. "That's what it's going to take."

Told of the court order yesterday. Deputy Commissioner of Corrections Elmanus Herndon said: "That's incredible," and then fell into silence for several seconds.

An aide to the governor said he does not know what the state will do if it has to meet the eight-month deadline."The only thing I can rule out is premature release of prisoners," said Thomas Peddicord, the governor's chief legislative officer.

Burch said the state will appeal the ruling of U.S. District Court Judges Alexander Harvey II and Stanley Blair immediately.

The judges, in separate opinions last May, had ruled that the two prisons are so overcrowded that conditions represent cruel and unsual punishment for the inmates and therefore are unconstitutional.

The penitentiary is the state's only maximum-security prison. Most prisoners here are serving lengthy sentences for serious felonies such as murder, armed robbery and rape, according to Deputy Commissioner Herndon.

The century-old House of Correction holds many of the same type of prisoners, but those who have been in the system longer and in many cases have been moved from the maximum-security penitentiary. Herndon said.

Burch said yesterday that none of the public officials involved "intended to participate in any program requiring the premature release of violent offenders or other prisoners whose release posed a threat to public safety."

But none of the state officials questioned yesterday offered any proposal for meeting the 8-month deadline if the state does not win its appeal of the order.

In their ruling last May, the judges found that the heart of the overcrowding problem was the widespread practice at both institutions of housing two inmates in one cell.

In the House of Correction, what the judges referred to as "double-celling" allowed more than 1,700 prisoners to be housed in a facility designed for 1,100 inmates, according to testimony in the case.

In the Maryland Penitentiary, which included the Maryland Reception. Diagnostic and Classification Center, there are more than 1,500 inmates - about 1,000 of the double-celled, according to the court opinion.

The judges found that the housing of two inmates in 40 to 44 square-foot cells offends "contemporary standards of human decency."

The rulings came in two class actions lawsuits against state officials brought by prison inmates.

Judge Harvey yesterday ruled that officials are permanently prohibited from double-ceiling inmates at the House of Correction.

Judge Blair, however, ruled that the penitentiary may have up to 25 cells used for double-celling under certain circumstances, and that other prisoners may be double-celled if they give voluntary, written permission for the practice.

Specifically, the judges ordered officials to remove 100 prisoners from each institution by December. They then ordered officials to remove 100 inmates each month from each prison for the next four months after that.

Peddicord said he state will have no problem meeting the December deadline, but he is not know how it can meet the timetable ordered for the next four months.

The state's 22-month proposal for reducing the prison populations had relied on the 1980 opening of a new institution in Jessup to house 500 inmates, and a second facility in Hagerstown, scheduled for completion in 1979, that would house about 130, Peddicord said.

Attorneys for the inmates he proposed that the state be given a six-month deadline for reducing the prison populations.

They suggested that officials consider reclassification of prisoners; transfers of inmates to correctional camps; transfer to halfway houses: expedited paroles and the purchase or rental of temporary housing such as military installations or motels to meet the deadline.

Paul Bekman, an attorney who represents a House of Correction inmate, yesterday criticized the state for failing to be "innovative" and failing to look for alternatives to new construction to meet an accelerated deadline.

But Peddicord said the state had ordered construction speed-ups on two facilities to come up with the 22-month timetable.

Judge Harvey last May also found unconstitutional the use of a special confinement area in the Jessup institution, which he said "merely warehoused" inmates with psychological or psychiatric problems. Yesterday, he ordered officials to transfer actively psychotic inmates and others in need of treatment to appropriate state mental institutions and to close the special area by Dec. 1.

In the penitentiary case. Judge Blair found that an isolation area, intended to hold mentally disturbed inmates on a short-term basis, was instead being used for extended periods of time to house inmates without adequate professional care.

Yesterday, he prohibited officials from using the area for "punishment" of inmates, and set strict rules on its use.

The judges' rulings were similar to a federal judge's 1975 opinion that found conditions in the century-old D.C. jail unconstitutional because of overcrowding.

Bekman said the state would have to show that the rulings by Judges Harvey and Blair were "entirely erroneous" in order to win an appeal.