Soviet President Leonid Brezhnev strongly endorsed tonight the election of Gen. Wojciech Jaruzelski as Poland's Communist Party leader and expressed confidence that he would rally party ranks "against encroachments by counterrevolution."

"In your effort to realize these aims you will meet with understanding and support from the Soviet Communist Party and the Soviet state," Brezhnev said.

In a "Dear Comrade" message, the Soviet leader hailed Jaruzelski as a "prominent party and state leader" who has been a "consistent supporter of inviolable friendship" between Poland and the Soviet Union.

The message and other Soviet commentaries reflected guarded satisfaction here at the ouster of Stanislaw Kania as Poland's leader, and the emergence of a harder line at the recent plenum of the Polish Central Committee.

The Kremlin has been increasingly dissatisfied with Kania because of his inability to meet effectively a challenge posed by Solidarity.

The tone of Brezhnev's message to Jaruzelski was in marked contrast to the Soviet leader's cool endorsement of Kania last July when he was elected party leader.

In the "Respected Comrade" message to Kania at that time, Brezhnev avoided even the expression of customary best wishes for success in building socialism. The absence of personal compliments or any expression of confidence in Kania's leadership was seen then as reflecting Soviet misgivings about his policies.

Tonight, according to the text of the message to Jaruzelski distributed by the news agency Tass, Brezhnev said:

"We express confidence that at this crucial historical moment you will use all your great prestige to rally the ranks of the Polish United Workers Communist Party on the basis of Marxism-Leninism, in the interest of defending the socialist gains of the Polish working class and all working people of Poland against encroachments by counterrevolution and to overcome the political and economic crisis of the country and further strengthen the sovereignty of the Polish state under the leadership" of the Communist Party.

Despite Jaruzelski's association with Kania, analysts here believe the Soviets are gratified that the general was elected by a hard-line majority in the Polish Central Committee, and that he would be expected to endorse radical measures including the possible declaration of a state of emergency.