Prison guards at the crowded Maryland Correctional Institution in Hagerstown used riot gear and tear gas early yesterday to quell a midnight uprising of 40 inmates who had barricaded themselves in a dormitory.

One guard suffered a broken hand and another a broken foot, prison officials said. Five other guards and 12 inmates were treated at Washington County Hospital for cuts and bruises, and all were released in good condition by 7 a.m., according to hospital security director Lester Stoner.

Officials said the prison was back under control within 25 minutes, but guards and an attorney who represents inmates at the medium-security prison expressed concern that problems could persist because of chronic overcrowding there and throughout the Maryland prison system. The Hagerstown prison, built to house 745 inmates, had a population of 1,211 yesterday, officials said.

"The more inmates there are in the system, the more there are who aren't occupied with jobs or classes," said Baltimore attorney Paul Bekman, who represents inmates in a federal lawsuit against overcrowding at Hagerstown. "Idleness is probably one of the most difficult things to deal with in any prison."

However, prison warden James Tinney III said overcrowding is not the root of the problem. "These people were incarcerated for the same type of behavior on the street," he said. "It shouldn't surprise anyone that that type of behavior continues in jail. They don't need a reason and you don't need a sociological or philosophical analysis."

The state is under federal court order to ease overcrowding at Hagerstown and two other prisons. Recently, an appeals court approved some doubling up of inmates in single cells to solve the problem. State officials said they will ask a U.S. District Court judge today to allow continued double-celling at Hagerstown, although earlier court rulings ordered an end to it there.

Since mid-September, Hagerstown officials have moved 160 inmates into four new dormitories in the basement of a cellblock area in an attempt to ease overcrowding. Dormitories for 160 more are to be built, officials said. Gov. Harry Hughes recently announced he will support construction of a new medium-security prison near Hagerstown as part of an effort to ease the overall prison crowding problem in the state.

Yesterday's incident followed by less than two weeks a work stoppage by inmates at the Maryland House of Correction in Jessup, protesting a change in visitors' hours. There, prison officials ordered a lockdown, and state corrections commissioner Jon Galley has agreed to meet with inmates to discuss their grievances.

In Hagerstown, according to Tinney, 40 inmates barricaded themselves in their dorm at 12:30 a.m., removing all light bulbs and arming themselves with pipes, table legs and batteries wrapped in socks. Tinney said a riot-control squad of 25 guards ordered the inmates to disband, then fired tear gas and broke into the dorm when the orders were defied. The warden said the guards "encountered intense physical resistance" from inmates.

Officials declined to say what specific incident sparked the unrest, but one guard said it appeared to be a protest against the placement of one dorm inmate in isolation.

Some guards contend that the unrest is a response to stricter prison policies recently imposed by state corrections officials. Prison disciplinary rules have been toughened around the state, and fewer inmates are being placed in minimum-security facilities.

Maryland Correctional Institution officials imposed a lockdown at the Hagerstown facility from Oct. 26 to Oct. 30 after an escape attempt.