MOSCOW (AP) _ Soviet leader Mikhail S. Gorbachev, in remarks published Saturday, said his government wants ''very much'' to withdraw its troops from Afghanistan, but the United States seeks to expand the conflict.

The official Tass news agency issued a summary of an interview Gorbachev had earlier this month with the French Communist Party newspaper L'Humanite.

Portions of the interview were printed in L'Humanite's Saturday editions, focusing on Gorbachev's statement that Soviet dissident physicist Andrei D. Sakharov will not be allowed to emigrate because he still possesses state secrets.

The Tass summary provided additional details on other topics in the interview involving Afghanistan, the late Soviet dictator Josef V. Stalin and domestic issues.

Tass said Gorbachev, in an exchange of written questions and answers with L'Humanite, was asked if there is hope for an end to the war in Afghanistan in the near future and the withdrawal of Soviet troops.

It quoted him as replying, ''We would want that very much and will, within our capabilities, work toward that. The government of Afghanistan, as we know, holds the same position.''

But Tass said he added, ''There are external forces in that conflict, which broke out because of outside interference in the first place, which are interested in continuing and expanding it - these are Pakistan and the U.S.A.

''Western Europe can influence the course of events as well. I think that if the situation in and around Afghanistan were soberly evaluated there and, of course, if our interests and the interests of universal peace were weighed up, the ways to assist the solution of the problem would be found.''

His remarks were a rare public reference by a Kremlin leader to the Afghan war and the presence of Soviet military units there.

The Soviets sent troops into Afghanistan in December 1979 to help the Marxist government battle anti-communist rebels, and now has an estimated 115,000 military personnel in the country.

Moscow has maintained that the Soviet troops were sent to Afghanistan after the government asked for help against the rebels, saying they were being backed by America, Pakistan and other countries.

Tass said Gorbachev cited recent moves by Afghan President Babrak Karmal to bring people from outside his party into the government as evidence of efforts to return life to normal.

Another issue that generally goes unmentioned by Soviet leaders is the Stalin era - 29 years of mass repression until Stalin's death in 1953.

Tass reported Gorbachev was asked if vestiges of Stalinism remain in the Soviet Union and it said he replied: ''Stalinism is a concept made up by opponents of communism and used on a large scale to smear the Soviet Union and socialism as a whole.''

Gorbachev then made a rare reference to the 20th Communist Party Congress, held in 1956, when then Soviet leader Nikita S. Khrushchev denounced Stalin's regime as a cult of personality.

Following Khrushchev's ''secret speech'' to the Congress, Stalin's name virtually disappeared from Soviet public life.

Tass quaoted Gorbachev as saying, ''Thirty years have passed since the question of overcoming Stalin's personality cult was raised at the 20th Party Congress and since the Communist Party Central Committee passed a resolution on that question.

''Truth to tell, these decisions did not come easy to our party. It was a test of party principles and of loyalty to Leninism. I think that we have withstood the test with honor and drawn proper conclusions from the past.''