The 4th U.S. Circuit Court of Appeals lifted yesterday an order that required Maryland to remove 1,000 inmates from two overcrowded prisons by next May. State officials had called the order a "substantial threat to public safety."

The court extended the deadline for removal of the inmates to June 1980, as the state has asked.

The order came in response to the state's appeal of orders issued in August by U.S. District Court judges concerning the maximum security Maryland Penitentiary in Baltimore and the medium security House of Correction in Jessup.

In separate opinions last May U.S. Judges Alexander Harvey II and Stanley Blair had ruled that the two prisons were so overcrowded that conditions there amounted to cruel and unusual punishment and were thus unconstitutional.

At the heart of the problem, the judges found, was the common practice at both institutions of housing two inmates in one cell, often no larger than 40 or 44 square feet.

The Court of Appeals, according to Maryland Deputy Attorney General George Nilson, who was informed of the decision yesterday, affirmed the finding of cruel and unusual punishment, but directed the District Court to give the state 22 months from last August to correct conditions.

"That's what it's going to take," Acting Gov. Blair Lee III said earlier this year of the 22-month proposal.

In complying with the order, Nilson said that state expects to make use of new inmate facilities expected to be completed at Hagerstown by February and Jessup by June 1980, housing a total of 628 inmates. Officials said the parole program also would be accelerated.

Under the original court order 100 inmates were to be removed by this month from the penitentiary and house of correction, and 100 inmates each month from each institution for the next four months.

The state, which has proposed to remove inmates at an average rate of 25 a month from each institution, has removed 69 from double cells at the house of correction.

Although the removals were at a lower rate than proposed officials said the June 1980 deadline could be met.