Maryland's state government, after three years of luxurious budget surpluses, appears headed toward fiscal hard times that could preclude further tax relief and lead to cutbacks in several major programs.

"The era of large surpluses appears to be over," state Comptroller Louis Goldstein said yesterday, after reporting that a budget surplus that reached $300 million last year had dropped to $55 million -- a thin cushion that could fund state government for only three days.

State officials said that the shrinking surplus may lead to a fractious year in which sectors of the government will soon be fighting with one another over limited resources. They predicted that departments and state-funded agencies ranging from transportation to higher education to health may have to get by next year with less money or the same amounts they had this year.

Maryland's fiscal worries are coming a few years later than in many other states and cities around the country. But state officials said the fiscal squeeze was the inevitable result of a deepening recession that has caused heavy layoffs, contributing to a decline in state income and sales taxes. Those two taxes are the state's primary sources of revenue.

Until now, Maryland has been a relatively recession-proof state, cushioned by a population weighted with government employes and by the strong Washington-area economy. "Now, said one state fiscal official, "every state is becoming susceptible."

Income tax receipts have been declining in July and August, the first two months of the 1981 fiscal year, officials said. In 1980, they fell $6.7 million below expectations, while sales tax receipts were $4 million lower than predicted. The decline in the growth of sales tax revenues began last March, when President Carter introduced dramatic credit-tightening measures.

Another reason officials cited for the shrinkage is a series of tax relief measures instituted by the Hughes administration in 1979, which trimmed the size of the surplus by $124 million this year. However, tax cuts took even more out of the 1979-80 budget, officials said.

The $293 million surplus of 1979-80 was the highest in several years. The year before, the state had a surplus of $89 million, compared to $79 million in 1978, $49 million in 1977 and $10 million in 1976.

Gov. Harry Hughes, calling the surplus estimates "bad news," said he expects no increase in sales or income taxes to make up the slack. However, the forecast makes it unlikely that he will proposee significant tax relief measures in the 1981 legislatived session.

The chief victim of the sagging revenues is the state's transportation trust fund, which relies heavily on a 9-cent-per-gallon engine fuel tax. Hughes would not rule out the possibility that he will seek an increase in that tax. Without added transportation revenues, the state will be forced to forgo severely needed highway repairs and other projects, officials said.

With spending kept to last year's levels, state employes will probably have to go through the year with little or no pay increase, several officials predicted.

Deep cuts are considered unavoidable in the state's Medicaid program, which now forecasts an $80 million deficit for this year, of which $51 million would be borne by the state. The state health department is now preparaing a list of options for coping with the debt, officials said.

Serious economic ripple effects are expected in city and county governments, since all of them benefited during the years of plenty from generous state subsidies. Hughes warned local governments yesterday that the state probably will be unable to increase those subsidies in 1981. In cities such as Baltimore, where the state funds were used to help pay police salaries and where federal funds are also imperiled, the situation has caused concern among many officials.

Finally, the possibilities of expansions or reforms at state hospitals, colleges and universities will be virtually choked off in an era of tight finances. One budget analyst predicted that state colleges may be forced to raise tuition and fees to meet costs without increased state aid.

The large surpluses of the last three years came from windfalls in the state lottery, from corporate and personal income taxes, sales taxes and from interest on the state''s investments. Last year's record surplus was attributed to overly conservative spending policies in the face of a anticipated recession that didn't arrive on time.

Goldstein, speaking with more optimism than Hughes about the present revenue projections, said he expects the economy to improve after the inauguration of the next president in 1981. New or reelected presidents generally bring on infusions of federal funds, the comptroller said.

In addition, many officials predicted that economic conditions could change dramatically by the time the 1981-82 budget takes effect, and certainly by the time the budget year ends.

Hughes is to use the budget figures released yesterday as the basis for drawing up his 1981-82 budget, which will be presented to the General Assembly in January. He said he asked for the estimates earlier than the traditional mid-December release date in order to tailor his proposals to the reality of dwindling resources.

Although the estimates were not heartening, officials said they do represent a $20 million increase over the original projections used when this year's budget was drawn up. At least half the increase was attributed to projected state lottery receipts, which would have suffered if the District of Columbia had approved a proposed lottery earlier this year.