MANAGUA, Nicaragua — On a recent Sunday, Managua’s auxiliary Roman Catholic Bishop Silvio Baez talked to those gathered for Mass about love and its many forms.

It soon became clear that Baez wasn’t speaking just to the 300 people sitting on plastic chairs in the sweltering heat, but also to President Daniel Ortega.

Dozens of young protesters had been killed in several days of clashes with police and the president’s supporters, during protests set off by proposed social security cuts that then veered into calls for Ortega to step aside after a decade in power.

“To denounce and publicly demonstrate against the actions, historic processes, political decisions that go against the great majority is also to love,” Baez said. And he added, if one’s presence is causing instability “to relinquish, to leave can be an act of love.”

So began the latest turn in a 40-year dance between Nicaragua’s predominant religion and Ortega, the former Marxist guerrilla who once infuriated the Vatican but gradually forged an alliance with the Church.

The protests, which have continued on a smaller scale, have forced Ortega into a corner and he has asked for the Church to mediate. Talks were scheduled to begin Wednesday after the president agreed, at least initially, to meet the Church’s conditions, one of which is to “review Nicaragua’s political system from its roots to achieve an authentic democracy.”

Ortega controls the national police and military, while the supreme court and congress strongly lean his way. Opponents accuse him of tilting the electoral field in his favor. But the protests led by students and supported by the business community and the Catholic Church are posing the greatest threat to his government since he won the 2006 election and returned to power 16 years after losing it.

“Clearly at the moment we’re in the pendulum swing again where the bishops are more critical of the government. They feel it’s more favorable to distance themselves, to make very clear demands,” said Henri Gooren, associate professor of anthropology at Oakland University in Michigan and editor of the Encyclopedia of Latin American Religions.

Ortega said that he and his wife, Vice President Rosario Murillo, would attend the talks Wednesday.

Church leaders have already been laying out those demands.

“We hope there would be a series of electoral reforms, structural changes to the electoral authority — free, just and transparent elections, international observation without conditions,” said Bishop Rolando Alvarez of Matagalpa. “Effectively the democratization of the country.”

A priest in Alvarez’s diocese was wounded in the arm by shrapnel Tuesday while trying to separate protesters and police in Matagalpa, but was out of danger, according to a statement from the diocese.

Ortega’s relationship with the Church has been long and tumultuous.

For years, the Church was close to the Somoza dynasty that had ruled the nation from the mid-1930s. But as the corruption and abuses of Anastasio Somoza became difficult to ignore, Archbishop Miguel Obando y Bravo began to distance the Church from the authoritarian regime in the 1970s while Somoza was trying to beat back threats both from civilian opponents and Sandinista guerrillas.

The Church twice mediated between the Somoza regime and the Sandinistas during hostage situations. But it was not until shortly before Somoza’s 1979 fall that the Church — like much of Nicaraguan society — openly supported the Sandinistas.

That support did not last once the Sandinistas began governing. Sandinista supporters repeatedly clashed with conservative bishops, who were scandalized by the Marxist-influenced priests who backed and served in Ortega’s government and by the growth of a Sandinista-backed “People’s Church.” Hostility may have peaked in 1983 when Pope John Paul II came to Managua, scolded the maverick clerics and ordered Catholics to obey their bishops and avoid “unacceptable ideological commitments.”

By the time Ortega lost the elections in 1990, the Church had long since moved back toward its close relationship with Nicaragua’s conservative elite.

Out of power, Ortega repeatedly tried to mend relations with the Church, increasingly expressing religious faith and calling for reconciliation with his foes. Bishops remained wary. Addressing voters ahead of the 1996 election, Obando y Bravo alluded to Ortega by telling the story of a man who was bitten after taken pity on a dying snake. In 2001, at a time when Ortega was fighting rape allegations by his stepdaughter, Obando y Bravo urged Catholics to look for candidates who “have been exemplary in their families.”

But gradually, there was a thaw. In 2005, Ortega and Murillo, his longtime partner, married in the Catholic Church in a ceremony presided over by Obando y Bravo.

Ortega steered his Sandinista Front lawmakers to support a total ban on abortion passed shortly before the 2006 election “as a gift to the Catholic Church,” said Einar Berntzen, associate professor of comparative politics at the University of Bergen in Norway. A week before the vote, Obando y Bravo, who had recently been replaced as archbishop, gave a sermon widely interpreted as endorsing Ortega’s candidacy.

Cardinal Leopoldo Brenes, who replaced Obando y Bravo in 2005, is considered more cautious, Gooren said.

But in the wake of April’s violent crackdown, Brenes has said the demonstrations were justified.

On April 20, hundreds of student protesters sought refuge in Managua’s cathedral, where the church was collecting donations to support protesters. When police and Sandinista Youth descended, demonstrators retreated to the cathedral and left that night only after clergy negotiated their safe passage.

That day, Brenes and several of his bishops made public statements against violence and in favor of dialogue.

The following day Ortega said he was willing to negotiate the social security changes, but only with the business sector. The Episcopal Conference issued a more forceful statement.

“We urge the country’s authorities to hear the cry of the young Nicaraguans” to repeal the reforms, it said, and it condemned the crackdown by groups tied to the government. “There are social sins that no human being can ignore, but rather must denounce, above all if they desire to restore the violated rights of the most vulnerable: our retirees.” That message was echoed in Baez’s recent sermon.

The next day Ortega canceled the social security overhaul and asked the Catholic Church to mediate a dialogue.

“We deeply appreciate the willingness of his Reverend Eminence, Cardinal Leopoldo Brenes, and all of the bishops to continue to contribute to dialogue, tolerance and peaceful coexistence in our country,” Ortega wrote to Brenes.

Berntzen said he saw Ortega as “temporarily weakened.”

“Since the Catholic Church is and remains a very respected institution, it appears the Catholic Church now perceives that the Ortegas need the Catholic Church more than the Catholic Church needs the Ortegas,” he said.

Associated Press photojournalist Moises Castillo and writer Luis Manuel Galeano contributed to this report.