In one of the most touching and human moments of his Brazilian visit so far, Pope John Paul II walked among the residents of a Brazilian slum today and told them: "The church in this Brazilian land wants to be the church of the poor. The church does not want to serve those who create the tensions and cause the explosions of struggle among people."

The pope's words will also have a considerable political and social impact in Brazil and other countries of Latin America where the clergy and governments have been cautiously awaiting an indication from the Roman Catholic leader on the issue of wealth and poverty.

Support of the poor in many Latin American countries has meant opposition to the wealthy ruling class, with which the church, until recent years, was most closely identified.

The pope exhorted the rich and "especially those who have the power of decision" to "do everything so that, at least gradually, that abyss that separates the excessively rich, few in number, from the great multitudes of the poor, those who live in misery, does not deepen but diminishes; so that it tends toward social equality; so that the unjust distribution of riches gives way to a distribution more just."

Later, addressing Latin American bishops, the pope repeated the commitment to assist the poor but cautioned against the church identifying itself with political or economic movements, especially Marxism.

Some Latin American clergy have seen Marxism as an effective way to improve social conditions, but the pope said that turning to Marxism would mean "total politicization of Christian existence and the disappearance of the language of faith from the language of social sciences."

To demonstrate his concern for the poor and his approval for the Brazilian church's work on their behalf, the pope, on the third day of a 12-day Brazilian tour, visited Vidigal, a Rio favela, or shantytown, whose problems resemble the problems of slums areas in many major cities, except that here they are worse.

As in the Adams-Morgan or Shaw neighborhoods of Washington in recent years, poor black families are struggling to avoid being pushed out as the inner city becomes increasingly valuable to real estate speculators and the middle class.

But Rio's slums are worse than those in the United States. No more than a quarter of Vidigal's 2,500 wooden shacks have electricity, only 20 percent have running water, none has a flush toilet and, until two weeks ago, when things were improved in anticipation of the pope's visit, there was not one paved sidewalk and only one telephone for the 15,000 people who live in this favela.

Like other slums in Rio and Sao Paulo, Vidigal's lanes are no more than dirt paths. When it rains, they turn to mud. When it is dry, they remain damp from the sewage that drains into them. Desease festers and worms are common, especially among the children.

Then, too, Brazilians have none of the social welfare programs, food stamps and the like, that aid poor Americans. In slums such as Vidigal, those who do not work depend on a fairly strong sense of sharing among neighbors and an extended family structure to help them through the worst times.

Or, not infrequently, they starve.

According to Antonio Carlos, 30, who for the past two years has been the elected director of the residents' association of the Vila Vidigal, most of his neighbors exist on rice and beans because "meat is too expensive. There are people here who are hungry. How many, I couldn't say."

Alcoholism among parents is a problem, Carlos said, while drug use, mostly marijuana, is common among the young.

Vidigal had one school, one bar and no church until last month. Now it has a chapel, built by the government after the church hierarchy in Rio decided that Vidigal would be the slum the pope would visit as a gesture of his concern for the poor. Vidigal was never the worst slum to begin with, according to Ana Maria Noronha, a church social worker familiar with this and other slums in Rio, and now it has been vastly improved.

Besides the new chapel, additional telephones and new paved sidewalks, the government ordered all of the houses in Vidigal painted and began a crash program of electrifying those portions of the slum that had previously depended on candles and kerosene.

"The pope really should have walked through the mud like the people do," Noronha said the other day. But she acknowledged that most of the "faveladas" who live in Vidigal are delighted with the improvements that have been made as a result of the pope's visit -- even if the pontiff thought the chapel, sidewalks, telephones, electricity and brightly painted houses in Vidigal had been there all along.

Despite the poverty, though, Vidigal has always had one thing going for it, which is in part the reason it was selected for the papal visit.

The Vila Vidigal, which was begun almost 50 years ago when migrant workers from Brazil's destitute northeast began building their wooden shacks on the side of a deserted hill far from the center of Rio, is now quite literally among the most valuable pieces of property in the world.

The hill including Vidigal is contiguous with Copacabana, Ipanema and Leblon, three of the best addresses in Rio, where oceanfront apartments sell in the hundreds of thousands of dollars. Vidigal faces the ocean, is only a mile from the luxurious Sheraton Hotel and has one of this city's most spectacular views.

In short, Vidigal would be worth millions to a developer for a hotel complex, luxury apartments or single-family mansions.

Three years ago, the family that owns the property -- and 50 years ago wasn't concerned about the shacks on it -- suddenly tried to get Vidigal's 15,000 people removed so that the property could be sold to a French development company.

"We said we'd leave dead," Haroldo Barboza Candido, a Vidigal resident, recalled last week.

Like others in Vidigal, Candido works in a nearby hotel, earns a relatively decent wage, likes his proximity to some of the most famous beaches in the world and, as bad as things are in Vidigal, did not want to be removed to some distant public housing project -- or left homeless altogether.

The residents of Vidigal stood their ground and, at one point in 1977, lined their children up when the police came to move them out.

The press and the church heard of the protest and the police and city government backed off. The church collected over $100,000 to pay legal fees for a court battle that now looks as if it has succeeded.