In Brazil the Catholic Church has been losing ground to both evangelical competition and growing secularism. Before he became pope, Francis I once complained that Pentecostals “confuse a liturgical celebration with a samba school!”  Yet the diminishing appeal of his own church for the poor and the working class is partly due to its rejection of liberation theology.  Pentacostalism, with its faith healing, exorcism and health-and-wealth gospel, has called forth imitations in Brazil, as other religions try to compete with its appeal: the Catholic Charismatic Renewal since the late 1960s  and even Pentacostalism among mainline Protestants, like the Presbyterians and Methodists.  (The Catholic parish priest who was trying to deny an abortion to the 9-year-old rape victim was the star of the rocking Resurrection Band.)
By the eve of the Pope's 2013 visit, almost 20% of Brazilians had become members of Pentecostal churches, such as the Assembly of God, the Universal Church of the Kingdom of God  or its offshoot, the Worldwide Church of God’s Power.  In a time of rising living standards for many, Catholic teaching about "humility" has a hard time competing with the Evangelical embrace of prosperity.  And Evangelical churches bring religion to the people, with tiny chapels in the favelas and larger ones in former commercial buildings like used-car lots.
Catholics are switching not just to Pentecostalism, but also to mainline Protestantism and even leaving churches altogether. Young people increasingly chose “no religion” while women tended to shift instead to Protestant churches that are less restrictive about abortion and contraception.  During the 2007 visit of Benedict XVI the Universal Kingdom of God, even ran an ad campaign in defence of abortion rights.  Its bishop has come out in favour of totally decriminalising abortion, citing the miserable lives of unwanted street children and the unnecessary deaths of women from backstreet abortions. 
Despite Vatican doctrines, Brazilian women have increasingly been planning their families and, by the time of Francis' visit had only 1.83 children each, which is one of Latin America’s lowest rates and below replacement level. 
Nevertheless, none of this prevented the Vatican from arranging the secret signing of a concordat in the papal palace. And it was done with a president who vowed never to betray the country's tradition of separating church and state.
In recent years popes have also made two papal visits to Brazil, in 2007 and 2013, to try to shore up belief in the world's most populous Catholic country.
The Catholic Church condemns any effective contraception, as this “makes the Church fruitful”, providing her with new children through Baptism. However, when this threatens the Church's credibility, Canon Law allows penalties to be relaxed, to avoid what the Vatican calls “scandal” (aka “public relations disaster”). Thus the case of the raped nine-year-old who was carrying twins caused divisions in the Vatican, and Pope Benedict finally had to enforce “fruitfulness”. The article below contains the references, which were omitted from the published version.
President Lula da Silva needed Church support for his chosen successor, Dilma Rousseff and a concordat was part of the price. To hide this betrayal of Brazilian secularism, there was a secret signing at the Vatican, the Evangelical press kept silent, and bishops lobbied to avoid a congressional debate. Yet once the Vatican got its concordat, the Church attacked Dilma and got a further concession, that she stop insisting that a woman's reproductive freedom was a human right.
In the face of the curious silence of the media, the Brazilian journalist Alberto Dines hosted this TV debate on 25 November 2008 about the concordat secretly signed two weeks earlier. “There were hugs, there were blessings, there were pictures, but no statement on what was dealt with between the President and the Pontiff. In the days that followed the news was trivial, contradictory and clearly deceptive.” *
This “legal agreement” (“acordo jurídico”) is a wide-ranging concordat. It permits teaching religion in public schools (Art. 1.1), missionary access to indigenous people in nature reserves (Art. 3) and tax exemptions for the Church (Art. 15). It lends cover to abusive priests by granting the right to clerical secrecy outside the confessional (Art. 13) and makes it impossible to sue the Church for the damage they cause, since this concordat states that they are not employees. (Art. 16.1)
An alliance of anthropologists, gays, teachers, judges, as well as atheist, Protestant, pro-choice Catholic and Afro-Brazilian religious groups urged Congress in 2009 not to ratify the concordat. They protested that it violates the constitutional separation of church and state and also goes against the values of Brazil which support diversity. Here are translations of some of their statements.
Innocent-sounding measures in the 2008 Brazilian concordat have caused problems in other countries, including Italy, Germany, Slovakia, Poland and Hungary, the Dominican Republic and Malta. And the Brazilian concordat appears to help protect the Church against being sued over abusive priests, which even the Vatican estimates is widespread among the Brazilian clergy.
The Brazilian education law was clearly intended to foster tolerance of the country's religious diversity — not to bring sectarian teaching into state schools, as prescribed by the concordat. Also anchored in the concordat is the right of the Catholic Church to "independent missions".
This concordat embeds Catholic chaplains (and Canon Law) in the military, gives them a central location at the military headquarters and obliges the state to support them. This military concordat is mentioned enigmatically in the 2008 concordat, perhaps a move to get the unsuspecting Congressmen to ratify it retroactively. For the military concordat has a trick clause at the end — in Latin — stating that it comes into effect immediately, in other words, with no ratification by a democratic legislature
1. Full transcript of Pope's in-flight press remarks released, Catholic News Agency, 5 August 2013. http://www.catholicnewsagency.com/news/full-transcript-of-popes-in-flight-press-remarks-released/
2. Ryan Villarreal, “Why Catholicism Is Losing Influence To Protestantism In Brazil”, International Business Times, 17 July 2012. http://www.ibtimes.com/why-catholicism-losing-influence-protestantism-brazil-723323
3. R. Andrew Chesnut, “How the charismatic movement conquered Brazil”, Catholic Herald, 26 July 2013. http://www.catholicherald.co.uk/features/2013/07/26/how-the-charismatic-movement-conquered-brazil/
4. David Masci, “Why has Pentecostalism grown so dramatically in Latin America?”, 14 November 2014. http://www.pewresearch.org/fact-tank/2014/11/14/why-has-pentecostalism-grown-so-dramatically-in-latin-america/
5. “The exorcists”, Guardian, 15 January 2001. http://www.theguardian.com/world/2001/jan/15/religion.uk
6. “Brazilian evangelist has big plans for U.S.”, Religion News Service, 1 April 2013. http://www.religionnews.com/2013/04/01/brazilian-evangelist-has-big-plans-for-u-s/
“‘Milagres’ e milhões. A ascensão meteórica da Igreja Mundial do Poder de Deus”, Instituto Humanitas Unisinos (IHU), 28 March 2010. http://www.ihu.unisinos.br/noticias/noticias-arquivadas/31035-milagres-e-milhoes-a-ascensao-meteorica-da-igreja-mundial-do-poder-de-deus
7. "Catholics in Brazil" (video), Canadian Broadcasting Corporation, 26 July 2013.
8. “Brazil’s Roman Catholics shrink as secular rise”, Associated Press, 8 October 2011. http://www.guardian.co.uk/world/feedarticle/9885696
[Interviewof the study’s author] “O brasileiro está feliz!” - Entrevista com Marcelo Neri
Os Emergentes dos Emergentes: Reflexões Globais e Ações Locais para a Nova Classe Média Brasileira, Revista ESPM, 31 July 2011. http://www.fgv.br/cps/bd/clippings/nc1694.pdf
[Study, whose summary begins on p. 47] Novo Mapa das Religiões / Coordenação Marcelo Côrtes Neri.
Fundação Getulio Vargas, 2011. http://www.fgv.br/cps/bd/rel3/REN_texto_FGV_CPS_Neri.pdf
9. “Record apóia aborto, e Universal doa camisinha”, Fohla de S. Paulo, 13 May 2007. http://www1.folha.uol.com.br/fsp/brasil/fc1305200718.htm
10. (Bishop) Edir Macedo, “O que é matar?” 22 November 2010. http://www.bispomacedo.com.br/2010/11/22/o-que-e-matar/ He also runs a pro-choice blog : http://www.bispomacedo.com.br/2010/12/21/aborto-crime-contra-quem/#more-6011
11. “In Brazil, a Laboratory for Reversing Catholicism’s Decline”, New York Times, 14 February 2013. http://www.nytimes.com/2013/02/15/world/americas/in-brazil-growing-threats-to-catholicisms-sway.html
"Religion in Latin America: Widespread Change in a Historically Catholic Region", Pew Research Center, 13 November 2014. http://www.pewforum.org/2014/11/13/religion-in-latin-america/
This report mentions African and indigenous elements in both Catholicism and Protestantism, like the "evil eye", witchcraft, reincarnation and offerings to spirits.
“Why is Latin America cooling on Catholicism?” Economist, 22 July 2013. http://www.economist.com/blogs/economist-explains/2013/07/economist-explains-15
“Evangelical Christians gain political clout in Catholic Brazil”, Reuters, 09 June 2013. http://www.reuters.com/article/2013/06/09/us-brazil-evangelicals-idUSBRE95805120130609
“Brazil’s Changing Religious Landscape”, Pew Forum, 18 July 2013. http://www.pewforum.org/2013/07/18/brazils-changing-religious-landscape/
David Masci, “Why has Pentecostalism grown so dramatically in Latin America?”, 14 November 2014. http://www.pewresearch.org/fact-tank/2014/11/14/why-has-pentecostalism-grown-so-dramatically-in-latin-america/