KRAKOW, POLAND -- Stanislaw Lem had been back in Poland from his western home in Vienna only three days this month when, still feeling the jolt of an East-West transition, he picked up a Soviet magazine and discovered a personal meaning for glasnost.

"I was reading Novy Mir and all of a sudden I saw myself," the writer blurted as he opened the door of his stunning, privately built house here one hot afternoon. "They are printing my novel 'Futurological Congress.' Before they didn't want to print that book. Before there was always some kind of political muddle. Now suddenly everything is okay."

A stack of Russian-language periodicals stood next to Lem's living room fireplace. Copies of Pravda and Izvestia were strewn on the leather couch of his wood-paneled study upstairs. Three days back in the East, this most prolific and popular of Polish writers, now living most of each year in comfortable western quarters, was already finding himself swept up in the changes of the restricted literary world he worked decades to transcend.

"It's like reading detective fiction," Lem said of the Soviet press. "Everything there is glasnost now. I would say that in Poland, really, nothing special of this kind is happening. No real change. But I think that if Gorbachev has it his way, this will be irreversible, and everything in all the other {socialist} countries will have to go the same way."

The excitement of this white-haired, 66-year-old iconoclast of an author over the political developments in Moscow is as heartfelt as it is touched with a characteristic air of detachment. For Lem, perhaps more successfully than any other East European contemporary, has found his own way to sidestep the quandary of writing under communist rule -- the imperative to collaborate or emigrate, serve one's art or the party.

He calls his distinctive solution "reality-based" science fiction, a genre he says is alien to both the western "escapism" and eastern "utopianism" of typical science fiction. "I have always resisted the label of science fiction," he said, rambling through an interview in colloquial Polish. "I've always believed in science, but I write about the real world. So I write about what is happening, only in my own way, in my own terms."

The result has been more than three dozen highly original novels, including a score published in the United States, and a remarkable mix of usually antithetical honors and privileges. Approved by both communist censors and common readers, Lem is published in the millions of copies in Poland and Japan, East Germany and West Germany, the Soviet Union and the United States. He has avoided confrontation with Polish governments, yet he retains the respect of both dissident writers and western critics, who acknowledge him as a major artist.

For the last six years, Lem has shuttled freely between homes on the eastern and western sides of Europe, unhindered in his writing, monetary fortune or remarkable status. Like composer Krzysztof Penderecki, another nominal Krako'w resident, he seems to be regarded by Polish authorities as a kind of international cultural showpiece, exempted from the normal constraints of East Bloc life in tacit exchange for his retention of citizenship.

Lem describes his situation as an uncalculated, if welcome, consequence of his particular sensibility.

"I, of course, realize that thanks to the fact that I write science fiction I can talk about a lot of things that in another style I couldn't," he said. "This is true. That was my luck. But I can't say that I was so smart that I knew 30 years ago when I started out that it would turn out this way. I never planned it like that."

In fact, Lem's early career in Stalinist-era Poland followed an erratic course as the young medical school dropout, the son of a secularized Jewish family from Lvov, struggled to find a way to express his exotic ideas within the prevailing strictures of socialist realism.

His first novel, the starkly naturalistic "Hospital of Transfiguration," about an insane asylum during the World War II German occupation of Poland, was held up by censors in 1948. Lem then produced two utopian science fiction stories set in a distant, untroubled future. By the time "Transfiguration" was finally allowed into print after Poland's liberalization in 1956, Lem was famous in the East Bloc as a science fiction writer.

The author now concedes that he was pushed toward science fiction utopianism by Stalinism, and regrets it. "My first two books -- which I now never release for reprinting -- there's nothing Communist Party about them, but there is this wonderful world that could evoke in a certain sense the communist utopia," he said, "now I won't allow them to be republished because I simply stopped believing in the utopia."

Lem never published another "utopian" book, but he also never returned entirely to his initial naturalism. Instead, his major works, such as "Solaris," "Futurological Congress" and "The Invincible," were nominal science fiction stories that often advanced a bleak view of man as a creature unable to find a stable place in the universe or control the consequences of accelerating technological advances.

With their sometimes abstruse concepts of cybernetics and other sciences and their tricky neologisms, Lem acknowledges, his books have grown both more difficult and more pessimistic in outlook over the years.

"My editors tell me that I am losing readers because my books are so hard and so pessimistic. Readers want pure escapism, they want something like {J.R.R.} Tolkien," he said. "But I'm not interested in writing about another world, I'm interested in writing about this one. And there are a lot of reasons for pessimism."

His latest book, "Fiasco," published in May in the United States and warmly received by critics, is depicted by Lem as an example of his efforts at "extrapolation on the real world." Its story concerns a spaceship sent from Earth in the 24th century to attempt communication with a planet whose population has turned the space around them into a war zone for increasingly autonomous weapons.

" 'Fiasco' is simply the model of a closed civilization that lost," Lem said, "which based itself on conflict, on the escalation of arms. And committed suicide. And of course that is a realistic scenario."

Apart from these broader, and superpower-neutral, themes, Lem can point to some instances where he used his brand of storytelling to indirectly describe the failings of East Bloc communism. In "Dialogue," a book published in Poland in 1957, he used cybernetical terms and images to depict a system doomed to "oscillation," or recurring failures and political crises.

"Why was I able to write this? Because in that book there were no political terms," Lem said. "Party, Politburo -- these words were not necessary for me. And the authorities are very afraid, mainly, of certain words."

Nevertheless, Lem rarely criticized communist authorities openly or supported opposition activities. During the legal period of the independent trade union Solidarity and the subsequent era of martial law in the early 1980s, he remained aloof, actively backing neither union nor party. In 1982, he accepted an invitation to spend a year in West Berlin, and since receiving another invitation to Vienna the following year, Lem has spent only summers and holidays in Poland.

Although he has remained enormously popular at home, with more than 2 million of his books printed and quickly sold since 1982, Lem is occasionally criticized by opposition intellectuals for his failure to speak out, especially when martial law was declared in December 1981.

Perhaps partly because of that criticism and partly because of the emerging mood of glasnost, Lem seems to have grown more outspoken about politics in recent years. He was quick and blunt in expressing his distaste for the present Polish government under Gen. Wojciech Jaruzelski, and supportive of Soviet leader Mikhail Gorbachev in the sense that he seeks to reform a socialist system Lem views as an "anachronism."

"Here in Poland we have a stalemate," Lem said. "The crisis, the degradation, gets worse and worse. The nation can't do anything and the authorities can't do anything. But Gorbachev has gone so far that there could be changes from the top to the bottom in our countries. I don't rule it out, not because Gorbachev is so terribly in favor of democratization, but because he has experts telling him he must do it."

Meanwhile, Lem thinks he has found another real-life topic to engage his imagination. "What I find very interesting and very incredible is AIDS," he said. "I have thought about writing something based on the idea of AIDS as an automatic control mechanism created by nature because of the population boom."

He smiled, a little sadly. "AIDS sounds too incredible -- if it were invented by a science fiction writer it would be a bad idea, too implausible. But that's what I mean: I find the real world much more interesting, much more unexpected, than any other world."