Poland's Supreme Court ruled today that the country's independent trade federation, Solidarity, did not have to accept changes made in its charter by a lower court and the union promptly called off strikes that would have plunged the nation into a serious new crisis.

The union, as part of a compromise worked out over the last several days by its lawyers, agreed, however, to attach an annex to its charter that indirectly affirms the leading role of the Communist Part in Poland.

The surprise compromise, which brought jubilation to members of the 10 million-worker union and relief to Polish authorities, was hailed by both sides as a victory for common sense and for Poland's future.

After the ruling by the three-judge court, Polish authorities lifted a ban imposed yesterday on the entry of foreign journalists into the country. The sudden ban as well as hard-line criticism in the Polish and Soviet press of the union's plan to strike if the decision were unfavorable had raised fears here of a serious new national crisis.

"You can't speak of winners or losers," Lech Walesa, head of Solidarity and the leader of Poland's independent trade union movement, said after the Supreme Court's ruling. "It was the proper solution to the problem."

Warsaw authorities reaffirmed their intention to work "in serious partnership and cooperation" with the new independent unions, formed after a series of summer strikes that began at the huge Lenin Shipyard in Gdansk and spread to other Baltic Coast industrial centers and across the country.

After the high court declared that a lower court had exceeded its authority by writing a declaration of Communist Party domination into Solidarity's charter and deleting portions asserting a right to strike, Walesa emerged from the sandstone grey court building beaming.

"We have achieved what we set out to on Aug. 31," he said, referring to the date on which government and striking workers signed an agreement guaranteeing the existence of independent trade unions in Poland.

"However, this is the beginning. In front of us is a big line of work and everyone has his own piece of this line . . .. Everyone has to go to work and work hard."

Today's court action marked a formal end to the first phase of development of the new national union group -- the first independent labor unions in any communist-ruled country -- and the working out of a new balance of power in Poland. Walesa's statement pointed to the second, and likely more difficult, challenge the union and the country now face: reviving and reforming the Polish economy, crippled after months of labor unrest and years of mismanagement.

While the court's decision gave rise to optimism about the ability of the Communist Party and Solidarity to work successfully together, the path ahead remains filled with sensitive issues -- including media access, wage scales and national labor legislation -- that could easily spark new confrontations.

Both sides are having to wrestle with divisive currents within their own groups, complicating the problem of relating to each other.

Solidarity, having expanded rapidly from the small strike committee in the Gdansk shipyard last summer to a nationwide organization, is still defining structure and tactics. The Polish Communist Party, demoralized by the labor upheaval, is going through intense debate about itself and trying to restore its authority.

Cautioning prudence and helping to keep the peace between these two evolvng forces is Poland's third power, the Roman Catholic Church. Immediately after the court ruling, Walesa and Solidarity's national coordinating committee went to see Cardinal Stefan Wyszynski, Poland's primate.

"Justice has begun to reign in the country," Walesa declared, greeting Wyszynski in the cardinal's private residence and handing him a bouquet of flowers. "The worst is over."

Until today, Solidarity and the government had appeared to be gearing for a confrontation against a background of extensively prepared strike and threats of counteraction by the government.

But in the small courtroom, the mood turned conciliatory. The government prosecutor openly conceded that the district court had overstepped its prerogratives by interfering with Solidarity's charter. Solidarity's lawyers, in turn, offered to attach an annex that, among other points, included the communist principles the government had sought to have written into the charter itself.

The annex has two parts. One is a restatement of article one of the Gdansk agreement, which says that the nw unions will recognize the leading role of the party in the Polish state and will respect Poland's international alliances. Union leaders had objected to the insertion of this wording into the actual charter, arguing that this would imply the party played the same role in the union's operation.

The second part of the annex includes portions of the International Labor Organization Convention guaranteeing the rights of trade unions against government interference and outlining relations between employers and employes. gThe 1949 convention was ratified by Poland in 1956.

The central sticking point had been how to include in Solidarity's charter a statement of Poland's basic communist principles. Reference to these somewhere in the document was important not only to the Warsaw leadership but particularly to Poland's Soviet-led allies, worried that the new free unions will undermine communist control.

But two weeks ago, during his first visit to Moscow since being named Polish Communist Party chief following the summer's strikes, Stanislaw Kania appeared to win Soviet backing for Warsaw's own strained efforts at trying to reach an understanding with Solidarity.

Today's compromise would seem to strengthen the government's hand here in showing it can deal on its own with the country's determined labor movement.

"The government welcomes with satisfaction the overcoming of the tension which had arisen in connection with the registration of Solidarity," the government said. "Resolving that issue creates full conditions for normalization of ther union's activity."

Polish television showed film Saturday of what it said were joint tank and aircraft maneuvers with the Soviet Union on previous days.

The sources said Western experts, who monitor Poland with sophisticated electronic surveillance systems, had detected no unusual troop movements.

The experts were said to believe that Polish television was showing film from its archives. Part of the four-minute film showed summer foliage and dust clouds but none of the snow said to have blanketed northern Poland last week. The film closed with soldiers in winter gear.

The sources said the showing of an archive film could have been aimed at intimidating the Solidarity independent trade union federation, which had threatened to strike.