FATIMA, Portugal (AP) _ Pope John Paul II arrived in this city on Sunday to celebrate the 74th anniversary of a vision of the Virgin Mary that is said to have warned of the coming of communism to Russia and Eastern Europe.

The 70-year-old Polish pontiff has revived interest in the Virgin and this town. Residents say a vision of her appeared on May 13, 1917, and gave three messages to the three shepherd children who are said to have seen her.

Of the messages, known as ''the three secrets of Fatima,'' the first included a vision of hell. The second contained a prophecy on the end of World War I and the outbreak of another world conflict as well as a warning of dangers looming if what was then revolutionary Russia ''spread the errors of her ways in all the world.''

The Vatican has refused to release the contents of the third secret.

On Monday, exactly 74 years after the reported vision, John Paul plans to say Mass for up to 1 million people, celebrating one of the great mysteries of the Roman Catholic church.

The service, which has attracted hundreds of thousands of pilgrims, will be held on the esplanade of Fatima's huge basilica.

''Thank you, heavenly shepherdess, for guiding people to freedom with maternal affection,'' John Paul said Sunday at the beginning of a two-hour vigil in the Fatima sanctuary. He also offered thanks for his salvation from a would-be assassin's bullet 10 years ago in St. Peter's Square in Rome.

But Fatima is more than the location of a reported miracle; it has become a rallying point for Catholic anti-communists.

The three children told their story on the eve of Russia's Bolshevik Revolution in October 1917. They said Mary told them if her wishes were fulfilled, ''Russia will be reconverted and there will be peace. If not, Russia will spread her errors throughout the world.''

On Sunday, John Paul reminded pilgrims at Fatima that he had the white- robed statue of the Virgin of Fatima brought to St. Peter's Square where he performed the act of consecration in March 1984.

A year later, Soviet leader Mikhail Gorbachev began his campaign of glasnost, his policy of openness that led to the demise of communist regimes in eastern Europe and the return of religious freedom.

Last month, as a result of his Vatican meetings with Gorbachev in 1989 and 1990, John Paul appointed the first Roman Catholic bishop in Moscow in 60 years, clearing a major obstacle for a papal visit to the Soviet Union.

For Monday's Mass, the pontiff has invited several special guests. They include Gennady Gerasimov, the former Soviet Foreign Ministry spokesman who has been Moscow's ambassador to Portugal for the past three months, and 84- year-old Lucia Dos Santos, the last surviving shepherd child who is said to have witnessed the miracle. She is now a cloistered nun in Carmelite convent in nearby Coimbra.

''In Portugal, the faith is rich and the people are poor,'' said Marion Janowski, who joined 53 others from Phoenix, Ariz., for the Fatima pilgrimage. ''In the United States, the people are rich, but the faith is poor.''

Earlier Sunday, Pope John Paul visited the Atlantic island of Madeira and told the Portuguese population it should avoid hedonistic excesses of the ''leisure society.''

Speaking to 40,000 people gathered in a specially enlarged soccer stadium, the pope said leisure time, which in many countries exceeds working hours, offered new opportunities for ''authentic humanism'' and spiritual activities.

He deplored that for the sake of efficiency, work had turned into ''an arid experience, reduced to automatic gestures and mechanical movements ... deprived of human relationships.''

Madeira and its surrounding islands lie 595 miles southwest of Lisbon and were first settled by the Portuguese in the early 15th century.