Since 1976, when Maryland Gov. Marvin Mandel authorized the purchase of an old can factory in Baltimore to be converted into a penetentiary, prisons have been a source of nonstop headaches to the state's governor and the General Assembly.

And even in this era, when much of the political rhetoric here is directed at Washington, the mention of prisons quickly diverts attention to issues closer to home.

On Tuesday, a task force appointed last year by Gov. Harry Hughes will recommend that a new 1,000-cell prison be constructed in Somerset County, the most remote of the counties on the Eastern Shore. Hughes is likely to follow that recommendation and, if all goes well, the new prison will open sometime in 1987.

The search for this prison site has been typical in many ways: Arguments over where to put the prison, outrage from citizens where the prison was contemplated, and enough changes in the unfolding plot to make a decent soap opera.

Two major factors, however, make the decision to build in Somerset unique and, in some ways, a watershed in terms of the state's future corrections policies.

First, Somerset is likely to get the prison because its five-member county commission made a rare request--they asked the state for it. Even though they had a 3-to-2 change of heart last week, their initial request probably will be honored.

Second, building a maximum-medium security prison in a rural setting, far from the environment where most prisoners come from, goes against much of the penal philosophy of the last 10 years. That philosophy held that prisons should be built where most criminals live and where they can be expected to return: urban areas. To put prisoners in a remote, rural setting, have them work on farms perhaps, was a waste of time.

Times have changed and so have those philosophies. "One of the most important things in building a prison is the kind of work force you can get to staff the prison," said Thomas W. Schmidt, the state's secretary of public safety and correctional services. "In a rural area, you're going to have much less turnover in staff than in an urban one.

"Also, you can build a bigger, more efficient prison and you can do it for less money," said Schmdit, pointing to an addition to a prison near Hagerstown that will come in for $10 million to $12 million less than its projected cost.

Schmidt concedes his view represents a change in prison philosophy.

In 1977, in a report to the legislature on prisons, Gov. Mandel emphasized the importance of putting prisons in urban areas. In 1980, when Del. Timothy F. Maloney (D-Prince George's), the chairman of the House subcommittee that deals with prisons, proposed building a prison in a rural location, he remembers, "the whole world came and testified against it. They said you just didn't do that."

Now, Maloney says, long-term prisoners probably will end up in the rural prisons.

According to legislative analysts, there is another trend: Communities are not adamantly opposed to prisons. In Illinois last year, Gov. James Thompson was greeted on a tour by townspeople holding a sign asking him to locate a prison there. A secure, maximum security prison in the neighborhood does not seem like such a big price to pay in the face of rampant unemployment.

Somerset County has been hit hard by the recession. Its unemployment rate is 17.2 percent, more than double the state average. A prison would create 500 jobs, with state-paid salaries of $12,000 to $20,000 a year, handsome in such an out-of-the-way area, and the work is guaranteed.

The prison also would help local businesses with an influx of friends and relatives who would visit prisoners.

The negative side is in the housing market, which is often adversely affected by having a prison in the neighborhood because new businesses tend to shy away from such an area. But given Somerset's economy, jobs, not selling houses, are a priority.

"I think the commissioners in Somerset showed a lot of foresightedness with their request," said Del. R. Clayton Mitchell Jr. (D-Kent), the chairman of the House Appropriations Committee and the man looked to by Eastern Shore residents to protect their interests. "I've said all along that I won't let the prison be built in any county that doesn't want the prison. But they want it, so as far as I'm concerned, they've got it."

However, last Friday, 10 days after giving the governor's task force a tour of potential sites, the Somerset County commissioners, under pressure from public reaction, voted 3-2 against the prison. Their vote was read to a crowd of about 700 that had gathered in Princess Anne to voice opposition to the prison. But even though representatives from the county will meet with members of the Hughes task force here on Monday, a belated political change of heart is unlikely.

"It's probably too late," said Michael F. Canning, one of Hughes' chief aides and a member of the task force. "They asked for the prison, they're probably going to get it. Certainly you want local support. But if you only put a prison in a place where everyone wanted it, you'd never get one built."

Hughes himself points out: "I doubt if there's a location in this state where you could put a prison that someone isn't going to be upset about it. what's just the nature of it. You wish you didn't have to build prisons but you do. It's that simple."

The history of this prison is a long and tangled one. It dates back to the state's purchase, for $2.9 million, in 1976 of the Continental Can Factory in Baltimore. The site was to be converted into a new prison. But even while the bulldozing work went on, city officials screamed that they didn't want another penal institution in the city, in addition to the state penitentiary and the city jail already there.

In 1978, Acting Gov. Blair Lee III, facing a tough election fight and needing support in the city, gave up on the site and sold the factory back to the city for $2 million, after having invested another $1.6 million in the site. Net loss to the state: $2.5 million.

"Blair made a political decision," said former Sen. Victor L. Crawford, who until this month was chairman of the legislative committee that eventually recommended the Eastern Shore site. "We desperately needed a prison. But he desperately needed support in the city and Mayor William Donald Schaefer and those guys were screaming."

Lee's political move did him no good, he lost the Democratic primary to darkhorse Hughes.

When Hughes was inaugurated in 1979, one of his appointments was Gordon Kamka, warden of the Baltimore City Jail, as secretary of Public Safety and Correctional Services. Kamka's policies were liberal. He believed in working at rehabilatation and in early parole, so he declared there was no immediate need for a new prison.

"That really set us back," Crawford remembered. "I don't care how liberal you are. We needed a prison."

Under fire, Hughes removed Kamka as corrections chief in March 1981, and began looking actively for a new prison site. Last winter, he asked the legislature to fund a 760-bed addition to a facility outside Hagerstown. Washington County was not thrilled, so the funding was done with a caveat: Hughes agreed to appoint a task force to examine whether the proposed prison was needed.

"Doing those projections was easy," said Schmidt, who succeeded Kamka and brought order to a system where there had been chaos. "You look at figures and make some assumptions. It was obvious we needed another prison. Then, as always, the problem was the site."

Hughes' task force and Crawford's committee reached the same conclusion: A new 1,000-bed facility was needed. Projections showed that the prison population, which stood at 11,058 this week in a system designed for a maximum of 7,500, would peak at about 12,500 in 1990. Then came the $64 question: Where would the new facility be put?

There was some sentiment to build in Prince George's County. The boys' village site in Cheltenham seemed to be a natural spot. But two factors blocked that idea, according to Crawford. "Prince George's has seven senators and 21 delegates, that's sizable political strength. Also, construction costs in the Washington area would have been incredible."

Others, notably then-senator Edward J. Mason, a member of Crawford's committee, suggested his home county, Allegany in western Maryland. But the terrain there is mountainous and, again, costs would have been prohibitive.

So attention turned to the Eastern Shore. Cecil County in the north seemed like the place for a while. There were two potential sites. But the best one, at Bainbridge, was on federally owned land that might be difficult to purchase. And the Cecil County commissioners were opposed to the prison. Still, the task force was ready to recommend Cecil when suddenly, officials from both Caroline and Somerset counties came forth and said, "How about us?"

The task force deferred its decision to hear out the two counties. Caroline's commissioners pulled out within a week though and Somerset emerged as the logical choice since the five commissioners were unanimous (then) in their desire to get the prison.

Now Somerset's politicians say they will ask Hughes to back off and go elswhere. That request probably will be refused, but the battle is still a long way from being over.

"You have to just DO it at some point," Mitchell said. "The fact is, anywhere you go, Someset, Cecil, pick a place, the same people screaming they don't want a prison are the same people screaming that all these people should be locked up. But they want it both ways, 'Lock Em Up,' they say, 'but not at my door.' That way of thinking will never change."