President Wojciech Jaruzelski resigned Saturday as head of the Communist Party and was replaced by the outgoing prime minister, Mieczyslaw F. Rakowski, who has become a champion of conservative elements in the party.

In another apparent victory for party conservatives, two hard-liners were named to the ruling Politburo in a shakeup that came on the last day of a Communist Party plenum.Four of the 18 Politburo members and five of the nine party secretaries - most reformers or linked to Jaruzelski - were dropped. Party spokesman Janusz Bisztyga called the move a drive for "new faces."

In addition to quitting as party chief, Jaruzelski also resigned from the Politburo and the policy-setting Central Committee in what appeared to be an effort to show total commitment to the presidency.

Jaruzelski had promised to give up the party post he held since 1981 if he became president. He was elected July 19 to the position, created as part of reforms agreed to in talks this year between Communist authorities and the Solidarity trade union movement.

As president, Jaruzelski has control of the military and foreign policy matters and will choose a prime minister to head the government.

The official news agency, PAP, said the gathering of the party Central Committee and party deputies of parliament elected Rakowski 171 to 41 to replace Jaruzelski. Bisztyga said Rakowski was the only candidate.

The selection of the 62-year-old Rakowski culminated a remarkable political rise by the politician who joined the Politburo only in December 1987 after having been dropped from the government in 1985, along with several other hard-liners.

"The party is in a difficult situation, but I believe I have support from thousands of party members," Rakowski told state television later. "I am aware of the importance of the job, and I believe that we can find a way out of this difficult situation."

Rakowski has been sharply criticized for the way he handled the economy during his nine months as prime minister.

But despite triple-digit inflation, food shortages and his plan to raise food prices Aug. 1, Rakowski was believed to have gathered support from hard-liners and party members fearful of the growing influence of Solidarity.

Rakowski is disliked by Solidarity for his antagonism toward the union during the martial-law crackdown of 1981 and for his decision last year to close the Lenin Shipyard, where Solidarity was founded nine years ago.

He was one of 33 senior officials who ran unopposed for Parliament in June elections but failed to capture even half the votes. He handed in his government's resignation last month after the new Parliament was seated.

Soviet President Mikhail S. Gorbachev immediately sent congratulations to Rakowski, saying cooperation between the Soviet and Polish parties will continue "in spirit of party friendship and mutual understanding," PAP said.

Jaruzelski was expected to present his choice for prime minister Monday for approval by the Parliament. Potential candidates appeared to be Politburo member Wladyslaw Baka; Deputy Prime Minister Ireneusz Sekula; and Roman Malinowski, the leader of the allied United Peasant Party.

Baka quit Friday as party secretary in charge of the economy after harshly criticizing Rakowski's performance as prime minister. His resignation was accepted during Saturday's session.

According to PAP, the plenum also adopted a resolution declaring the party's willingness to work with Solidarity and with the 260 Solidarity lawmakers chosen in the June election.

Solidarity now controls 99 of 100 seats in the new freely elected Senate and 161 of the 460 seats in the Sejm, or parliament.

The resolution reaffirmed the party's January decision to legalize Solidarity and "defined conditions" needed to improve the economy, PAP said, without elaborating.

Besides Jaruzelski, the Central committee accepted Politburo resignations from Jozef Czyrek, Kazimierz Barcikowski, Stanislaw Ciosek and Alfred Miodowicz. Miodowicz said he resigned because of wishes of members of the official trade union alliance OPZZ, which he heads.

They were replaced by Warsaw party chief Janusz Kubasiewicz and Katowice party chief Manfred Gorywoda, both hard-liners, and by Leszek Miller, a party secretary who has been active in promoting the party to young people.

Dropped as party secretaries were Czyrek, Ciosek, Baka, Marian Orzechowski and Zygmunt Czarzasty. Baka and Orzechowski remain members of the Politburo.