The Carter administration fought combined legal assaults from the AFL-CIO and two dozen Republican members of Congress yesterday in a critical showdown over enforcement of its anti-inflation guidelines.

At issue was whether-President Carter has the legal authority to deny federal contracts to companies that exceed the "voluntary" wage and price guidelines, the only direct sanction the administration has to enforce its already weakened guidelines program.

"Our answer is no," said AFL-CIO attorney Laurence Gold, who was joined by three senators and 21 House members in asserting that the sanctions amount to a severe penalty equivalent to the kind of mandatory controls that Congress has refused to authorize.

Congress has provided ample authority under procurement laws to "promote the policies it cares about" in acting as a "prudent purchaser," responded Assistant Attorney General Barbara Babcock in comparing the current dispute with litigation over anti-discrimination executive orders in the 1960s.

After hearing two hours of final arguments, U.S. District Court Judge Barrington Parker took the case under advisement and promised a ruling "as expeditiously as possible."

While rejecting an AFL-CIO request for a temporary restraining order against the administration last week, Parker said that, nonetheless, he thought "at first blush" that the labor federation had a strong argument on the merits of the case.

He didn't indicate yesterday how he would rule, but, in an exchange with Babcock, appeared to question just how voluntary the program is. Rather than threatening with a stick, the program says, "I may not give you a carrot," said Babcock, adding that "even a rabbit knows the difference." Parker suggested that the only difference was, "I'll hit you with a steel rod or I'll hit you with a 2-by-4."

But at another point Parker seems to lean toward the administration's arguments. "Isn't there a national policy against the economy running amok?" he asked. Not unless it's rooted in law, answered Laurence Silberman, who represented the members of Congress.

A ruling against the administration, even though it almost certainly would be appealed, would be devastating to the guidelines, which have already been battered by skyrocketing prices, union protests and a Teamster settlement that stretched the pay standard to its limits.

The pay guideline, which is the principal focus of the suit, seeks to limit wage and benefit increases to 7 percent a year. The price guideline seeks to keep price increases half a percentage point below the average for 1976 and 1977.

Capitalizing on existing exemptions and wheedling some new ones, the Teamsters last month drove away with a new three-year contract averaging 10 percent more a year. Now the United Rubber Workers is striking Uniroyal Inc. over the company's adherence to the guidelines, with negotiations apparently stalled until Parker rules.

The case is also expected to have a major impact on bargaining this spring and summer in the electrical and auto manufacturing industries.

Although the sanctions have never been used, the White House pointedly raised the threat of contract debarment last month against the Big Four rubber companies. And, earlier this week, Westinghouse Electric Corp., which does about 10 percent of its business with the government, cited the threat of debarment as a factor in its renewed pledge to stick by the guidelines.

In arguments before Parker, Babcock acknowledged that this is the first time the government has used its purchasing power to influence labor costs, but said the action is "strongly rooted in congressional authority" that also gave rise to executive orders banning discrimination against minorities by federal contractors.

Disputing Babcock's claim of congressional authority for the sanctions, Gold and Silberman said that anti-discrimination orders, "Buy American" preferences and other long-standing procurement policies have been specifically endorsed by Congress.

In contrast, they said, Congress banned mandatory controls in 1974 legislation creating the Council on Wage and Price Stability, passed in the aftermath of the Nixon administration controls program.

The GOP members of congress, who are generally conservatives, normally do not find themselves on the same side as the AFL-CIO, but join the unions in opposition to the procurement sanctions. Some of them also participated last year in a paper-workers union suit against the procurement penalty that was never decided on its merits.

The three senators are John H. Heinz III (Pa.), E. J. Jake) Garn (Utah and John G. Tower (Tex.). The House group is led by Rep. Jack Kemp (N.Y.).