A Maryland legislative subcommittee approved today the conversion of an old Baltimore factory into a medium security prison as one way of relieving a severe overcrowding in the state's jails and prisons.

The proposal passed the first of several legislative tests despite the intense opposition of neighbors of the factory and charges from some legislators that it would mean a windfall profit for a relative os Maryland Gov. Marvin Mandel's chief campaign fund-raiser.

There was also criticism of the unusual speed with which Mandel's office set up the leasing of the old factory, bypassing the normal bureaucratic channels to execute the lease.

The Joint Subcommittee on Law Enforcment and Transportation voted 6 to 4 to allow the state to acquire the abandoned Continental Can factory in East Baltimore to be renovated and used to house 890 inmates.

The factory is owned by developer Morton Sarubin, a cousin of Mandel's oldest friend and adviser Irvin Kovens, who is also a codefendant in Mandel's political corruption trial.

Last August, Sarubin bought the proposed prison site for $1.9 million. In December, Sarubin signed a contract, negotiated entirely within Mandel's office, guaranteeing him a minimum of $3 million and a maximum of $4.5 million through either a lease or a purchase of the property, subject to approval by the legislature.

Today's vote was the first of at least five legislative tests the prison proposal must pass. An element of Mandel's budget, it must be approved by the budget committees of the Senate and the House of Delegates, then by the full membership of both bodies.

Today's vote was delayed by a last minute appeal to subcommittee members to turn it down by Del. John Douglass (D-Baltimore), who represents one of two neighborhoods adjacent to the proposed prison site.

Douglass said he opposes the location of a prison at the old Continental Can Co. factory because negotiations for the prison were carried on in secret in Mandel's office, because of the threat to the communities, and because of the profit Sarubin stand to make.

"The question is . . . whether this committee needs to endorse a multi-million dollar ripoff of Maryland's taxpayers," Douglass said.

With Douglass were about 15 residents of Kenwood, a middle-class black neighborhood whose inhabitants fear the coming of a prison would be stroy their community.

"You have no conscience, no conscience at all," one woman told committee members in a sudden outburst. "If this was going near your home, you'd feel like we feel," said another.

Maryland has a serious prison overcrowding problem; there are more than 2,000 inmates for whom the state is responsible but does not have adequate facilities to house. Many of them are double-bunked in cells built for one man, or jammed into crowded, old local jails.

The Continental Can site offers advantages of size - 25 acres, room enough for later expansion - and availability, but the disadvantage of its location near the two stable communities.

"It's almost as if I'm voting against motherhood if I vote for this," said Del. Charles Avara (D-Baltimore), who later voted in favor of the proposal. "It puts me in one hell of a position."

The subcommittee defeated an amendment offered by Del. Nancy Kopp (D-Montgomery) to require that the prison built at Continental Can meet the standards of the American Correctional Association, the nation's leading prison-rating group.

"I have faith in the state of Maryland" to build an adequate facility, said Del. Andrew O. Mothershead (D-Prince George's).