Six months after Pope John II's unifying visit here, relations between Brazil's combative church and conservative military have deteriorated sharply.

In his 12-day journey through the world's most populous Roman Catholic country, the pope came down squarely, and unexpectedly, on the side of the poor. He implicitly endorsed the social activism of the Brazilian church -- considered by many the most militant in Latin America.

As in the pope's native Poland, the church here has long opposed the violation of human rights in the name of economic progress. Last year, Brazilian bishops called for sweeping land reform and opened their churches to union meetings during a bitter metalworkers strike.

By the end of the pope's triumphant, 10,000-mile tour -- the first papal visit here -- the welcoming smiles of the ruling military were wearing thin. The pope's plane had barely cleared the treetops in June when the government counterattacked with a law empowering authorities to expel any foreigner who violates vaguely defined "national interests."

Although the pope would presumably be exempt if he returns, foreigners account for one-fifth of Brazil's bishops and one-half of the country's 13,000 priests.

"The foreigner's law was aimed directly at the church," the Rev. Decio Teixeira, head of the Brazilian Conference of Religious Workers, changed in a recent interview. Although he could not cite precise figures, Teixeira said that since August "many" foreign priests and nuns have been denied visas.

Using the new law, the government expelled an Italian priest in October for refusing to celebrate mass on Brazil's independence day, a national tradition. The priest argued that his parishioners, rural cane-cutters in the northeast, were not independent because of their poverty. The Catholic hierarchy solidly backed the priest.

In the sour aftermath of the deportation, generals and bishops traded charges of "Marxist clergy" and "religious persecution" -- a far cry from the harmonious days of 1964 when the church hierarchy backed the military coup.

Encouraged by one deportation, conservative politicians have called for more, but the government is avoiding new tangles with the church. Justice Minister Ibrahim Abi Ackel, author of the foreigners' law and son of a Lebanese immigrant, toured the country in November trying unsuccessfully to pacify the Catholic hierarchy.

A Gullup poll found overwhelming sentiment against the expulsion, and wide-ranging elections are scheduled for next year. The church commands a powerful and expanding network of 100,000 organizations -- Bible study and social action groups involving about 2 million lay people, all potential voters.

The pope's visit may not have smoothed over differences between church and state, but his climb into the hillside shantytown of Vidigal buoyed the spirits of Rio's slumdwellers.

Moved by the poverty he found, John Paul II spontaneously pulled from his finger a heavy golden ring he had worn for 13 years. He gave it to Vidigal, a jumbled favela, or slum, of 15,000 people that is left off most city maps.

Today, the ring is taken to monthly meetings of the Rio favela association, where, according to Vidigal's priest, the Rev. Francisco Xavier, "it is blessed and kissed as a symbol of solidarity."

"The visit brought us together. People have more faith in one another," Carlos Duque recently said. Vice president of the neighborhood association, Duque guided the pope to the inauguration of a small whitewashed chapel in Vidigal.

"We built the church," Duque said. "Every favela is doing it this way -- the government won't recognize you as a human being, so if you want to improve things, you have to do them yourself."

On Sundays, his day off from driving a bus, Duque joins 30 other men laying sewer lines with plastic piping, cement, stones, and sand donated by a local business.

From his three-room house, a rough window frames a spectacular view of a slate gray sea sweeping out to three, low islands on the horizon. The view is worth millions and for almost a decade a French company has been trying to evict the slum's residents to build a luxury hotel.

In the past, the government evacuated slums at gunpoint and then bulldozed or burned the shacks. But, in the wake of the pope's visit, Rio's mayor suddenly declared the 40-year-old slum "in the public interest." Now residents can buy their plots of land.

"Everyone is fixing up their house," said Euque's wife, Maria Lurdes.

Indeed, wheelbarrows and piles of sand clutter the meeting hall of the neighborhood association. Posted against an unfinished wall is a list of the group's goals: "sewers, mail, garbage containers, paving, church, nursery, medical station."

At the end of a recent weekly reunion, association president Armando A. Lima rose with a letter in his hand and asked for silence.

Standing in the half-finished room, in the neighborhood that is left off city maps, he slowly read a Christmas card from the pope to the people of Vidigal.