PRAGUE, APRIL 21 -- Pope John Paul II, on his first visit to a Warsaw Pact country since the collapse of communism, condemned the communist ideal as a "tragic utopia" but also urged his fellow Slavs to beware of abandoning spiritual values in their rush toward economic and political integration with Europe and the wider world. His words echoed the concern of Catholic leaders here about the dangers of rapid absorption of Western culture.

"Civilization cannot rest on a restricted vision of man, such as that of materialism," the pope said at Prague Castle this evening. "We need to regain an integrated vision which takes man in all his dimensions: spiritual and material, moral and religious, social and ecological. . . . Without a sense of the transcendent, any type of culture remains a formless fragment, like the unfinished Tower of Babel."

John Paul II's arrival in the Czechoslovak capital for a two-day visit marks the first time a pope has set foot on Czechoslovak soil.

Tens of thousands of citizens, some of them weeping, turned out to cheer him along the 14 miles from the airport to Prague Castle. Later, an estimated 300,000 people braved late afternoon rainstorms to fill the large field known as the Letna Plain to celebrate Mass.

The pope said his mission was to begin reconstruction of a church reduced to skeletal form by four decades of the most severe anti-church repression experienced in any Eastern Bloc country. He told Czechoslovak Catholic leaders that their primary task was "evangelism," particularly revival of the priesthood. He also called on the Czechoslovak church and society to make the coming decade a time of spiritual rebirth, "a kind of training ground for a new lifestyle for the next millennium."

Czechoslovak President Vaclav Havel, who in his inaugural speech in January invited the pope and the Dalai Lama to Czechoslovakia, called today's visit by the pope a "miracle."

"I do not know whether I know what a miracle is," Havel said in his welcoming speech at the Prague airport. "Nonetheless, I dare say I am party to a miracle now: The messenger of love comes into the country devastated by the ideology of hatred; the living symbol of civilization comes into the country devastated by the rule of the uncivilized; the messenger of peace . . . of unity in variety comes into the country devastated by the idea of confrontation and division in the world."

Havel, who comes from a Catholic background, had a 15-minute private meeting with the pope, during which he made an "informal" confession and received the pope's blessing, the president's spokesman said.

Flanked on the altar at Letna Plain by more than 100 cardinals and priests from Poland, West European countries and Czechoslovakia, the pope said the Catholic church here had been strengthened by its trials. He compared the imprisonment and suffering of Czechoslovak Catholics, including members of the now-decimated religious orders, to the sufferings of the early Christians.

"These trials have shown the value of your faith. For faith, like gold, is tested by fire," the pope said.

For the most part, the crowd on Letna Plain displayed characteristic Czechoslovak reserve. It was intense and reverent but subdued, lacking the boisterous exuberance that characterized the pope's three visits to his native Poland. Many people sat with eyes closed, some smiling, others brushing tears away. People hushed those who spoke above a murmur.

The pope singled out as "revered and intrepid" Czechoslovakia's 90-year-old Cardinal Frantisek Tomasek, an outspoken critic of the Communist regime in the 1980s, when human rights abuses and persecution of church members intensified.

In Czechoslovakia, where the Communists required that priests be licensed by the government, there are now 22 bishops. In 1988, there were only two. Six of the new bishops were first ordained unofficially in the underground church that existed alongside the official one during Communist rule.

The Vatican views the pope's visit as an important symbol of the dramatic change in church-state relations in the former Eastern Bloc brought about by the democratic revolutions of last year.

Thursday, the Vatican restored diplomatic ties with Czechoslovakia. Relations with Hungary were resumed in February, and limited diplomatic links with the Soviet Union were announced last month. Relations with Romania may be in the offing. The pope has scheduled trips to Hungary and Poland.

The pope's visit here also is an important and visible milestone in this country's passage from the Communist to Western spheres of nations.

The Dalai Lama arrived in Czechoslovakia within a month of Havel's invitation. The Vatican, which usually schedules the pope's trips months and sometimes years in advance, moved almost as quickly.

The visit comes less than two months before Czechoslovakia's first free elections since World War II, and that timing has led some Czechoslovak Protestants to worry aloud about increased Catholic influence in the affairs of state.

Earlier this month, the Vatican daily newspaper quoted Czechoslovak Deputy Prime Minister Jozef Hromadka, a Protestant theologian, as saying that monolithic communism must not be replaced by monolithic Catholicism.

Vatican officials, however, have been at pains to emphasize that the church has no political purpose. The Rev. Dominik Hrusovsky, rector of Rome's Slovakian Institute, who has responsibility for expatriate Slavs, said the visit was of a "purely pastoral" nature.

Nevertheless, the pope's trip cannot but help the already glowing image of President Havel, whom the pope today praised for the farsightedness of his invitation. In the crowd on the Letna Plain, some nuns wore Vaclav Havel buttons on their habits.

In his speeches today, the pope referred to the tensions that have emerged since the revolution between the country's two major ethnic groups, the Czechs and Slovaks. Friday, the Czechoslovak legislature adopted a new official name for the country, the "Czech and Slovak Federative Republic," in deference to Slovak feeling that the country's old name gives them inadequate billing.

The pope's schedule is equally divided between the Czech lands of Moravia and Bohemia, and Slovakia, which is the Catholic heartland. After today's Mass in Bohemian Prague, Sunday's schedule includes a Mass in the Moravian shrine city of Velehrad, seat of an important 10th-century Catholic mission.

The pope delivered the first half of his arrival speech in Czech and the second in Slovak.