Soviet President Leonid Brezhnev tonight warmly welcomed the selection of Stanislaw Kania as Poland's new leader and called him a "staunch" Communist firmly commited to "the inviolable friendship" between Poland and the Soviet Union.

In a message that went beyond the routine congratulations, Brezhnev praised Kania as a champion of "the leading role" of the Communist Party and expressed "the firm conviction" that Poland would quickly overcome its current difficulties.

Referring to the political turmoil that climaxed in the downfall of Edward Gierek, Brezhnev extended his specific endorsement to Kania.

"In the conditions of struggle for the consolidation of [Poland's] socialist gains," Brezhnev said, "you display a principled attitude, courage and high consciousness of the communist duty."

A somewhat more restrained message by Premier Alexei Kosygin to the new Polish premier, Jozef Pinkowski, also expressed confidence in continued "brotherly friendship, inviolable unity and fruitful cooperation" between the two countries.

The messages, distributed by the government news agency Tass, clearly were designed to demonstrate support for the new leadership in Warsaw.

Political observers here see Moscow's effusiveness as a tactical move -- indicating strong Soviet approval and hopes of restoring confidence in the communist government of Poland -- which does not suggest that the crisis is over.

Major problems remaining include not only the question of ideological heresy in the Polish recognition of independent trade unions, but also the sheer cost of the promises and pledges made to striking Polish workers.

Earlier in the day, Tass reported Gierek's removal as the result of "a serious illness." The fact that Gierek lost not only the Communist Party secretaryship but also his seat in the Politburo was a clear signal that he was removed for political reasons, however.

Gierek's ouster had been expected in informed circles here. His name disappeared from the Soviet press earlier this week and East European diplomats said Gierek's departure was inevitable after two government shake-ups, and particularly after the last one in August that failed to pacify the striking workers.

This had caused serious doubts here and elsewhere in Eastern Europe about whether Gierek was the right man to ride out Poland's economic and political crisis. Still, there were no suggestions here that Moscow had lost confidence in him personally. Gierek had a good personal relationship with Brezhnev, whom he met several times this year and most recently during Gierek's Black Sea vacation in the first two weeks of August.

Indeed, there are rumors among well-informed East European journalists and diplomats that Gierek earlier had offered to resign his post in a move to help settle the crisis.

It is not known precisely what precipitated his ouster at this stage and to what extent the Soviets may have been involved. But the scope of concessions Gierek granted to the striking workers, including the promise of independent trade union continues to be viewed from here with grave reservations.

The congratulatory messages and extensive publicity given to the new Polish leadership seem to be setting the stage for a new phase of the Polish crisis.

According to communist sources, the magnitude of Grierek's promises, including pay increases and other benefits, was such that it was obvious that he would not be able to make good on them. In this view, there are no short-term fixes, but rather a long and difficult path to reviving Poland's economy -- perhaps requiring further sacrifices from the population.

Meanwhile, the Soviets continued their campaign of vague threats and criticism directed at the promise to allow trade unions independent of the Polish Communist Party.

The Communist Party newspaper Pravda today accused President Carter of having encouraged the dispatch of Western funds to "antigovernment" forces in the port city of Gdansk.

Pravda said Carter did so in a meeting with AFL-CIO President Lane Kirkland and United Auto Workers President Douglas Fraser in late August.

"A large sum of money was sent to Gdansk to support those forces that stood on antigovernment positions," said the paper, to support "those groups that are working to divide the Polish united trade unions."

Soviet accounts of Premier Pinkowski's speech yesterday omitted all his references to the role of new trade unions.