Pope John Paul II called here this evening for "a new discovery of human and religious roots" in a country besieged by economic crisis and political violence.

Following a final day of activities in Ecuador, the pope landed at Lima's airport at sunset to begin the third and most challenging leg of his four-nation Latin American tour. He made his way by caravan to the city's center along a nine-mile route lined by tens of thousands of cheering spectators.

Thousands of police and paramilitary agents were deployed to provide security in Lima, which in the past two years has suffered from frequent blackouts and coordinated bombings by the Maoist group Sendero Luminoso, or Shining Path. Several top church officials criticized the government's security measures, which included a roundup earlier this week of about 2,600 persons considered criminal suspects.

Addressing Peruvian clergy and lay representatives tonight in the central Plaza de Armas, John Paul warned against attempts "to secularize our religious life" or "embark it on socio-political projects that should be alien to it," an apparent reference to the activism of some Latin American priests that has divided the clergy here.

He also declared that church teachings could not be "subordinated to political or sociological categories."

"It is the responsibility of everyone, particularly pastors, to ensure that the church does not lose its authentic image," he said.

At the same time, the pope explicitly endorsed a recent statement by Peruvian bishops that was sympathetic to the social doctrine of liberation theology, a controversial issue.

The Vatican issued a document last September strongly criticizing some aspects of liberation theology, a doctrine developed in Latin America in the late 1960s that encourages clergy to help organize the poor to work for social change.

Here the pope met a church sharply divided between conservatives and social activists who include the Rev. Gustavo Gutierrez, the first to write about liberation theology.

Gutierrez, who was the first to use the term "liberation theology" in a 1971 book, recently defended the use of Marxism and other types of sociological analysis by clergy. In contrast, three Peruvian bishops are members of the right-wing Opus Dei movement and one recently sponsored a congress to develop a "theology of reconciliation" as an alternative to Gutierrez's activism.

The competition between conservatives and activists sharpened when Cardinal Joseph Ratzinger, the author of the Vatican's critique of liberation theology, asked the Peruvian bishops to investigate the writings of Gutierrez. The bishops held four major assemblies but were unable to agree on a common position.

Finally, the bishops were summoned to Rome last September and held a series of meetings with the pope and Vatican officials. When they returned, they issued a compromise statement -- mentioned by the pope tonight -- that endorsed liberation theology as "a source of spiritual deepening" but authorized conservatives to review publications and control Catholic schools and religious societies to prevent excesses.

In his visit to Guayaquil, Ecuador, earlier today, the pope reiterated the issues of social justice that have emerged as a key theme since his 12-day visit to Latin America began last Saturday in Venezuela.

Touring the shantytown Guasmo, the pope declared that he wished to make "an urgent call to the consciences of those who govern" so that "they procure a greater social equilibrium and show even more solidarity with the needy and the suffering."

But the pontiff has also used his sixth tour of the region to reiterate his concern over the erosion of traditional family values. He preached against divorce, abortion and artificial birth control in Venezuela and warned congregations in Ecuador against "unnatural conduct and aberrant manipulation of man by man."

During his five-day stay in Peru, the pope has scheduled visits to six other cities as well as large masses in Lima's port of Callao and the Lima shanytown of Villa el Salvador.

Perhaps most dramatically, John Paul plans to travel to the Andean city of Ayacucho, the center of the war between Peru's armed forces and the Sendero Luminoso. His arrival will come only a week after the human rights group Amnesty International charged that security forces were responsible for major abuses, including more than 1,000 disappearances, in their drive to defeat the guerrillas.

The scheduled visit to Ayacucho has spurred hopes by human rights activists that the pope will condemn excesses by security forces.