Poland's communist authorities unexpectedly moved into a new confrontation with the country's independent trade unions today when a Warsaw court agreed to register them formally, but in the process ordered two controversial changes in their statute.

Union representatives immediately denounced "unilateral changes" and said they would never accept them.

One change would force the new national trade unions federation, Solidarity, to include in its charter language recognizing the leading role of the Communist Party in Poland. The other struck from the draft document a section defining the newly won right to strike.

The decision incited fresh tension between workers and the government at a time when some of the union leaders, including Gdansk strike leader Lech Walesa, had begun to take a more moderate line, cautioning against further strikes and trying to shift worker attention to the difficult problem of economic recovery.

Stunned by the ruling, which was read in open court after four hours of discussion on Solidarity's draft statute, Walesa swept angrily out of the court building to face a crowd of thousands filling the streets in front.

"This is not what we wanted," he declared. "This is not what we wished. They will not do us things that we do not want done."

Union leaders, who thought they had worked out a compromise with the government to end a month-long impasse on the registration issue, were shocked by the court's action and declared they would appeal the changes to the Polish Supreme Court.

Later, at a press conference held at a tractor factory here, Walesa's tone was even harsher. "Our statute was mutilated in a manner without precedence and without our agreement," the union chief stated. "We are indignant."

Walesa said the "unilateral changes" in the statute had put into doubt the Gdansk agreement, signed between Baltic shipyard strikers and the government Aug. 31. He announced Solidarity would never agree to them.

Why Polish authorities would make such a move sure to incite new worker unrest remained unclear. In recent days, Warsaw officials has sought to play down the registration issue, seemingly determined to get the thorny issue settled.

It was speculated that Polish leaders may have come under pressure from their Warsaw Pact partners, specifically the Soviet Union, to stand firm on the main objections to the draft statue.

In any event, today's action represents a sharp setback in the still highly explosive process of working out a new balance of forces in Poland. With the registration issue now likely to stay in the headlines for at least another two weeks while Solidarity prepares its appeal, efforts to bring the country back to normalcy are certain to remain frustrated.

The central dispute is over the wording of the first paragraph of the Solidarity charter, which in draft from avoiding explicit recognition of the leading role of the Communist Party, as well as an endorsement of socialism as the foundation of Polish society or any statement of respect for Poland's alliances.

These were key phrases included at government insistence in the Gdansk agreement and authorities expected to see them again in the Solidarity statute. Union organizers omitted them, arguing that the new federation is nonpolitical and so should not have political language in its charter.

Following private talks this week with government officials, Solidarity representatives thought the issue would be settled by attaching a protocol to the court registration.

At today's court hearing, Walesa personally and the union as a whole entered statements reaffirming the leading role of the party "in the state" while at the same time declaring Solidarity's nonpolitical status.

A second dispute was over the right to strike, granted workers in the Gdansk agreement though left vague. Government officials had expected the details would be worked out in the process of drafting a new trade union bill and labor code revisions. But Solidarity included a section defining when and how strikes would be called. The court threw out the section and substituted it with the sentence that a strike could be called if all other measures failed.

In explaining the court's action, Judge Zdzislaw Koscielniak said that rejection of the entire statute had been considered but that this was ruled out because of the high "social expectation" that registration would occur. He said that the "corrections" in the charter merely constituted an attempt to preserve Poland's existing laws.