The Mellon Bank Corp. of Pittsburgh, in a move that could alter commercial banking in Maryland and boost the political fortunes of Gov. Harry Hughes, agreed today to acquire Community Savings and Loan Association and give 20,000 depositors unlimited access to their money, which has been frozen since August.

In two agreements signed today, the state promised to pay Mellon $131 million in cash to take the crippled Bethesda thrift off its hands. The Maryland government also pledged another $40 million to offset possible future losses from Community's far-flung real estate holdings.

Under legislation approved by the House of Delegates and awaiting a vote in the Senate, Mellon would win the right to acquire bank holding companies in Maryland, a power that could significantly increase the pace of banking competition in the Washington suburbs.

Mellon, the 11th-largest bank-holding company in the nation, set a target date of early May to reopen eight of Community's nine branch offices as the new Mellon Bank Maryland, freeing $324 million in deposits. To complement the state's cash payment to cover Community's deposits, the Pennsylvania company pledged $179 million.

Mellon also agreed to inject more than $23 million into its new Maryland outpost.

"It's sort of a happy marriage of our interests and your interests, which I think will work out very well for all of us," said Mellon Bank Chairman J. David Barnes.

Barnes' appearance this afternoon at a news conference gave Hughes an opportunity to defend his handling of the state's savings and loan crisis, which began last May with depositor runs at several thrifts.

As conservator and insurer of Community, First Maryland Savings and Loan Association of Silver Spring, a small Baltimore thrift and the giant Old Court Savings & Loan Association of Baltimore, the state is liable for estimated losses of roughly $400 million.

The transaction requires passage of legislation now pending in the General Assembly, and approval by state and federal banking authorities and Baltimore Circuit Court Judge Joseph H.H. Kaplan, who is overseeing the Community conservatorship.

Last October, Hughes was jubilant after a narrow Senate vote cleared the way for Chase Manhattan Corp. to acquire three other distressed thrift associations in exchange for full banking privileges in Maryland.

Hughes, an almost certain candidate for the U.S. Senate, seemed similarly delighted today.

"We have carefully made sure we're not mortgaging the future," Hughes said today in response to a reporter's question. "So I stand here today feeling very good about the way we've handled this."

Earlier this month, Senate President Melvin A. Steinberg, a wily legislative tactician who delayed the Chase Manhattan deal, threatened to play havoc again, this time with the Mellon transaction.

Steinberg (D-Baltimore County) complained that Mellon was asking the state to put up too much cash and pledge far too much money -- about $60 million -- to offset possible future losses. Steinberg softened his opposition today after Mellon agreed to a $14 million reduction in the state's cash payment and agreed to accept the lower $40 million pledge from the state. "I don't think the General Assembly at this stage would have a good reason to torpedo the deal," said Steinberg. "It's the prudent way to travel."

John McHale, a Community depositor and spokesman for a statewide depositors' group, said the terms of the Mellon deal "sound good to me." But, he added, "a solution ought to be provided for every depositor. It's clear now that Old Court depositors won't be treated equally at the end of the process." State officials have said that some Old Court customers will have to wait four years -- until that thrift's assets are liquidated -- to recover all their money.

Community, once a staid savings and loan, was transformed in the early 1980s into a cash machine for a gigantic real estate empire known as EPIC. Community's former principals are the target of a multimillion-dollar suit by the state and dozens of creditors have gathered in a U.S. bankruptcy court in Virginia to sift through the wreckage of EPIC.

Under the terms of today's agreement, Mellon is largely insulated from losses in the EPIC portfolio. Hughes said that as the state tries to liquidate its EPIC holdings in the coming years, it stands to lose as much as $80 million, an amount that could be reduced by the "very, very significant recoveries" that Hughes said he expects the state to win through legal actions.