PRAGUE, Czechoslovakia (AP) _ Pope John Paul II and President Vaclav Havel on Saturday celebrated Czechoslovakia's peaceful revolution that toppled the Communists, portraying it as a victory over spiritual darkness.

Hundreds of thousands of faithful welcomed the Polish-born pontiff as he made his first visit to Eastern Europe since a pro-democracy tide ousted the region's hard-line Communist leaders last year.

''It is the first time I have seen so many believers around me, people who do not fear to show their faith,'' said 25-year-old Martin, a Franciscan studying for the priesthood in the Moravian city of Brno.

The Roman Catholic leader's two-day trip, which includes stops in Velehrad and Bratislava on Sunday, was hastily arranged at Havel's request to allow John Paul to lend his support to democratic change. The pontiff was last in Eastern Europe in June 1987, when he visited Poland.

In a prelude to the trip, the Vatican and Czechoslovakia restored diplomatic relations Thursday after a 40-year interruption. As barriers have fallen throughout Eastern Europe, the Vatican has moved quickly to forge ties with countries with centuries of Christian tradition.

''I daresay ... I am participating in a miracle,'' said Havel, a nominal Catholic who only last year was jailed by the hard-line Czechoslovak regime for his dissident activities.

''The messenger of love comes into a country devastated by the ideology of hatred; the living symbol of civilization comes into a country devastated by the rule of the uncivilized,'' he said.

John Paul, speaking of the entire region, said communism had proved itself to be a ''tragic utopia'' because it denied the spiritual needs of man.

He assailed what he called the ''violent application of a materialistic ideology'' that had paralyzed the nations of Eastern Europe.

Huge crowds standing eight deep waited during sporadic thunderstorms to watch the pope's motorcade pass through the narrow cobblestoned streets leading to the spired gothic cathedral and Hradcany Castle, the presidential residence.

An open-air Mass on the Letna Plain, for decades the site of staged Communist Party extravaganzas, drew an estimated half million people, including many from neighboring Poland waving Solidarity banners. The crowd stayed despite a raging 10-minute cloudburst and intermittent rain throughout the two-hour service.

Nevertheless, the mood of the throng was cheerful for what was believed to be the biggest Mass in Czechoslovakia since before World War II.

The pope turns 70 next month and who was making the 46th foreign pilgrimage of his pontificate.

Referring to the country's former rulers, he said at the Mass, ''The ones who feared truth and freedom feared Christ.''

He urged Czechs and Slovaks to guard against divisive nationalist tensions. ''Now you have to unite and together step out into the future,'' he said.

The papal speeches were filled with praise and encouragement for the Czechoslovak church and its 90-year-old leader Frantisek Tomasek, for whom the visit is a vindication of decades of resistance to Communist pressures.

The church in Czechoslovakia suffered greater repression than anywhere in the Soviet bloc and up to 10 of its 13 dioceses have remained vacant for years.

In a meeting with members of the clergy, John Paul told them he was paying tribute ''to all your suffering, to listen to you, to ackowledge publicly the value of the witnesses of your church, and to thank you for it.''

He cautioned them however against what he called ''viruses'' from the West, listing secularism, ''hedonistic consumerism'' and atheism.

In the evening, the pope was scheduled to meet with Havel at Hradcany Castle and then deliver an address.

On Sunday, he was to travel to Velehrad and Bratislava. In Velehrad, 1985 celebrations were held to honor saints Cyril and Methodius, who helped spread Christianity in the Slavic world.

John Paul often deplored the state of the church in the East bloc and urged Roman Catholics in Czechoslovakia to remain firm in their faith.

But soon after the regime led by Milos Jakes was toppled by Czechoslovakia's peaceful revolution last year, restrictions on the church were lifted and long-vacant bishops' posts were filled.

Statistics released by the Vatican estimate 10.7 million Catholics live in Czechoslovakia, out of a population of 15.6 million.