The federal government notified Maryland officials yesterday that the state can continue setting its own hospital rates for Medicare patients as long as the state's cost of treating Medicare recipients increases at a slower rate than the national average.

The extension of the so-called Medicare waiver, which Maryland has enjoyed since 1977 and which is one of just four in the nation, was formally granted in a letter from the Health Care Financing Administration.

Maryland officials had been saying for months that their rate-setting system was in jeopardy because of increasing pressure by Congress and the Reagan administration to slow the soaring cost of providing medical care to the nation's elderly.

"We have what would appear to be some breathing room," said Andy Wigglesworth, Gov. Harry Hughes' aide on health issues. "However, the basic issue still is whether our system performs in the face of continued efforts at the national level to tighten up" on hospital rates.

Wigglesworth said the extension will remain in effect unless the rate of increase in hospitalization costs for Maryland Medicare patients exceeds the national rate of increase, based on the previous three-year period. Between 1981 and 1984, Maryland's Medicare costs rose at the rate of about 20 percent, while the national increase was 31.6 percent.

Maryland's Medicare waiver is regarded as a cornerstone of its hospital rate system under which the cost of treating indigent and uninsured patients is absorbed by all patients. In 1984, that bad debt and charity care totalled $142 million.

"This will mean the continuation of a system that has provided our citizens unparalleled access to quality care," said Wigglesworth. "It means that any citizen regardless of his ability to pay or insurance coverage can get access to hospitals."