Compromise legislation to keep federal antirecession aid flowing to the nation's cities has been worked out in the Senate, a delegation of the nation's mayors announced yesterday.

The new measure, fashioned by Sens. Edmund S. Muskie (D-Maine) and William D. Hathaway (D-Maine), would give financially ailing cities half as much money in fiscal 1979 as they would have received under a White House bill that is botttled up in a House subcommittee. That bill would have provided $1 billion a year over two years to the cities. The subcommittee voted last week to postpone consideration indefinitely.

Detroit Mayor Coleman Young and a spokesman for Muskie said the compromise legislation was worked out Tuesday, and approved by President Carter yesterday in a meeting wih 16 mayors.

White House urban policy officers could not be reached for comment.

The Muskie-Hathaway proposal is "two-tiered, geared to national and local unemployment rates.

For example, if the national unemployment rate remains at 6 percent throughout fiscal 1979, beginning Oct. 1, the measure would provide $500 million - as opposed to the administration's $1 billion - in urban antirecession aid.

The measure would then make available slightly more money for each percentage point increase above 6 percent.

If the national rate falls below 6 percent, the Muskie-Hathaway bill would keep up to $125 million available for each three months of the year, to be distributed to those cities and states whose unemployment rates are at, or above, 6 percent.

Under the measure, the whole urban antirecession aid program would cease if the national employment rate drops 5 percent for two quarters.

"This bill retains the philosophy of countercyclical [antirecession] assistance," a Muskie spokesman said. "It provides aid only as long as there is a need for aid."

In a joint press conference yesterday, Young, San Francisco Mayor George Moscone and Mayor Arthur Clark of Waltham, Mass., said they were relieved at the compromise.

"We believe that the countercyclical part has been salvaged," Young said. "We're fully in support fo the compromise worked out by the Senate leadership and agreed to by the president."

The mayors said they expect the measure to be offered as an amendment to a House bill now in the Senate.