Chase Manhattan Corp. and Maryland state officials have all but sealed an agreement allowing the New York banking giant to acquire the financially troubled Merritt Commercial Savings and Loan, state government and banking sources said yesterday.

The deal, if approved by the General Assembly, would ease a major headache for state officials, but could still cost the Maryland government at least $20 million, the sources said.

"We're in the fourth quarter" of negotiations, said Thomas H. Maddux, the Maryland economic and community development secretary who has led the negotiations with Chase.

"We're not snagged," Maddux added. "We're confident the deal will be consummated."

Gov. Harry Hughes is expected to report on this substantial progress at a news conference he is scheduled to hold in Annapolis today. The governor and Maddux are to leave Sunday on a 10-day trade mission to Europe.

Maryland officials are eager for Chase to acquire Merritt, which reported $340 million in assets earlier this year, because the sale of the Baltimore thrift would reduce a huge loss that the state government might otherwise have to cover. Merritt has been at the center of Maryland's savings and loan industry crisis that began last May and it remains under state conservatorship with its deposits frozen.

Although the sale of Merritt would ease a major fiscal problem for the Hughes administration, the agreement is likely to include as a plum for Chase a $20 million to $30 million payment from the state, according to government officials and industry sources.

Maddux said negotiations with Chase have centered on a "ballpark" $30 million payment to the New York bank holding company, which Chase could then use to offset any bad investments in Merritt's loan portfolio. Maddux stressed that the figure was "subject to lots of refinement" but he also indicated that it posed no major obstacle to concluding the deal with Chase.

However, such a large payment poses a long-run problem for an administration that only this week learned that the troubled Old Court Savings and Loan has a $175 million debt, officials said. Covering the Old Court debt could consume the bulk of the $190 million in insurance held by the Maryland Deposit Insurance Fund, the conservator of Merritt and Old Court.

Chase Manhattan, which has more than $86 billion in assets, already has formally annouced it will acquire Friendship Savings and Loan of Bethesda and made a bid to acquire Chesapeake Savings and Loan of Annapolis.

Its planned acquisition of Merritt represents the third and crucial leg of a deal to gain an early foothold in the lucrative Baltimore-Washington banking market. The General Assembly, which earlier this year imposed investment and job-creation requirements on out-of-state banks wanting to do business in Maryland, would have to approve Chase's three-way plan to open branches in the state.