D.C. government workers and schoolteachers are not entitled to the same wage increase their federal counterparts received this year, and Mayor Marion Barry acted legally in setting their salary scale without negotiations, a Superior Court judge ruled yesterday.

In a decision that represented a resounding victory for Barry and for D.C. home rule power, Judge James A. Belson upheld the decision of the mayor and the City Council to give city workers a 5 percent wage increase, substantially less than the 9.1 percent increase won by federal employes.

Belson's ruling affects about 30,000 D.C. government workers, school-teachers and employes of the University of the District of Columbia, and upholds the mayor and council on every aspect of the challenge to their actions under the city's comprehensive personnel act.

The effect of the ruling is far-reaching, since each year's salary becomes the base upon which future increases and pension payments are calculated.

Belson removed a cloud of uncertainty that has hung over Barry's administration since last fall. Had he ruled otherwise, the hard-pressed city government would have been liable for about $29 million in back-pay increases retroactive to last October. That probably would have doomed Barry's efforts to balance the city budget without further tax increases.

Barry said the decision "means that we will be able to keep more employees on the payroll, that we won't have to have additional layoffs, and that our financial situation will not be further damaged." He would have given the workers more if the city's financial situation had allowed it, he said, but "I hope our employes recognize the reasonableness of our position and the judge's ruling."

Until the current fiscal year, which began Oct. 1, D.C. workers generally had salary parity with federal workers. Under the home rule act, they lost the right to stay equal in pay and benefits with their federal counterparts, but they gained the right to collective bargaining, or negotiations, over salary, benefits and working conditions.

When former president Jimmy Carter gave federal workers the 9.1 percent wage increase for this year, unions representing D.C. workers demanded that Barry either give them the same thing or at least negotiate, rather than imposing a salary level unilaterally. Barry argued that the legal mechanisms for collective bargaining were not in place. He said further that there was only enough money in the budget for a 5 percent increase, which is what he gave, with City Council approval.

That was not only less than federal workers received, but also less than increases some suburban employes got. Montgomery County, for example, gave its workers 7.9 percent raises in the fiscal year that ended yesterday, and another 9.4 percent in the new year beginning today.

The city's Public Employee Relations Board ruled that Barry was required to negotiate retroactively. The mayor appealed to Superior Court, where he won a complete victory with Belson's 23-page opinion.

In the key section, Belson accepted the mayor's argument that the Home Rule Act severed D.C. employes from the federal salary structure. An ambiguous section of the act guaranteed D.C. workers "benefits, including but not limited to pay . . . at least equal" to those provided by Congress. Belson said that does not mean city workers must receive all cost-of-living adjustments obtained by federal employes.

"It seems highly unlikely," he wrote, "that Congress intended that all local personnel processes had to mirror in every respect their federal counterparts. This, in the Court's view, would be inconsistent with the congressional intention that the District develop a merit personnel system independent of the federal system."

Only the salary-setting procedures for 1981 were at issue. For 1982 and subsequent years, benefits and working conditions will be determined in negotiations that are now under way between the city government and the school board, the University and the workers' bargaining agents.