Maryland Gov. Harry Hughes, fighting his way past a horde of legislators anxious to have their pictures taken with him, signed into law today emergency legislation that exempts about 50,000 elderly Maryland residents from paying state taxes on their Social Security benefits.

The law, which goes into effect immediately and affects this year's tax returns, "decouples" Maryland tax law from federal provisions that for the first time tax the Social Security pay of single recipients earning more than $25,000 a year, and couples making more than $32,000.

Unless specific changes are enacted, Maryland tax law generally conforms with the federal tax code.

Though the law will cost Maryland about $7 million in revenue during fiscal 1985 and 1986, legislators rushed to embrace it, largely because of a forceful lobbying effort by the elderly. The legislation passed both the House and Senate on unanimous votes this month.

The popularity of the legislation, and the voting power of the elderly, were in evidence at the ceremonial bill signing by Hughes, House Speaker Benjamin L. Cardin (D-Baltimore) and Senate President Melvin A. Steinberg (D-Baltimore County) in the governor's reception room.

A full 10 minutes before Hughes emerged from his private office, legislators anxious to be included in the photos of the event already were jockeying for positions behind the conference table where the governor sits to sign bills into law.

"We're learning today about victory having a thousand fathers," observed Del. Gerard F. Devlin (D-Prince George's) as he watched the scramble for prime camera angles.

"There's Maryland's two champs fighting for the same inch," added Devlin as Comptroller Louis L. Goldstein and state Sen. Frank Shore (D-Montgomery) -- both noted for their ability to make the most of photo opportunities -- competed for territory like basketball players working for a rebound.

About 1 in 10 of Maryland's 500,000 Social Security recipients will be affected by the change. Those affected are instructed to use line 61 on their state tax returns to deduct Social Security or railroad retirement income.

Many of those benefiting from the change are from Montgomery and Prince George's counties, a fact that could easily be ascertained by the makeup of the crowd of legislators gathered behind the governor today. Of 17 legislators who joined the ceremony, 10 were from those two jurisdictions.

Del. Michael Gordon (D-Montgomery), one of the sponsors of the new law, said that failure to enact the change would have meant a double penalty for the elderly, who previously paid taxes on their gross pay before Social Security contributions were deducted.

"This gets the session off to a pleasant start," said Hughes as he put his signature to the first measure to be enacted by the 1985 General Assembly.