MOSCOW (AP) _ Prime Minister Nikolai I. Ryzhkov, who would lose his job in the government overhaul proposed by President Mikhail S. Gorbachev, set ambitious goals when he took the post in 1985.

One of his first and toughest tasks was to trim the bloated bureacracy inherited from the ''era of stagnation'' under the leadership of Leonid I. Brezhnev.

Gorbachev initiated the political and economic restructuring known as ''perestroika'' shortly after he became leader in 1985, and Ryzhkov was a key lieutenant in implementing reforms.

But the 61-year-old prime minister has not always agreed with his boss. ''Sometimes I clashed with him on practical issues,'' he said in an interview last summer with the magazine Arguments and Facts.

During his five-year tenure, Ryzhkov eliminated 25 ministries and dozens of other central officers were dismantled. In the interview, he described efforts to pare down the entrenched bureaucracy as ''a battle royal.''

Nevertheless, it was the same bureaucracy that he climbed through to reach the post considered the second most powerful in the country.

Ryzhkov was born on Sept. 28, 1929, to a miner's family. After graduating from the Urals Polytechnical Institute with a degree in engineering, he began working in 1950 at the giant Uralmash machine-building complex in Sverdlovsk. Twenty years later he became its director-general.

He joined the Communist Party in 1956 and became active in politics with his appointment to the Supreme Soviet Commission on Planning and Budget in 1974. In 1981, he became a full member of the party's Central Committee.

In 1985, six weeks after Gorbachev became general secretary, Ryzhkov was appointed a full member of the Communist Party Politburo. He was named chairman of the Council of Ministers in September of that year.

During his first years as prime minister, Ryzhkov was largely regarded as a faceless technocrat until he took control of a high-profile Politburo commission overseeing relief efforts for victims of the December 1988 earthquake in Armenia.

''Thanks to his TV image, many thought Ryzhkov a soft and irresolute man,'' the Novosti news agency said in a 1989 profile. ''That was so until the Armenian earthquake at the end of last year. The world then saw another man. The mask of reservation fell to reveal frankness and undisguised passionate pity.''

But his popularity proved short-lived.

Blame for the abysmal economic conditions sweeping the country was laid at his feet. For the past year, Supreme Soviet lawmakers, demonstrators and intellectuals have demanded the resignation of Ryzhkov and his government.

''Almost each parliamentary session over the past year began with demands for the resignation of the government, and this session hears the same demand,'' Ryzhkov told lawmakers Saturday.

''All this prevents the normal functioning of the supreme executive power body,'' he said. ''The atmosphere created around the government, in fact, dooms its decisions to non-implementation.''

Ryzhkov appeared philosophical about the imminent demise of his job, saying he only learned of Gorbachev's proposals 20 minutes before they were presented to the Supreme Soviet.

''I understood that the position of chairman of the Council of Ministers won't exist. There will be presidential rule, a presidential Cabinet,'' he said. The job of vice president, included in the Gorbachev proposal, was not offered to him, Ryzhkov said.

Despite the uncertainty of his future, Ryzhkov said he supported Gorbachev's restructuring plans.

But, he said, things will be just as tough under the new setup as they were under his government.

''It will be just as hard for them as us, because our life is such,'' Ryzhkov said. ''We really are at a pivotal stage when the old structure is still being broken down and the new one is being born.''