Last weekend’s abortion referendum was a defining moment for Ireland and a defining moment for the Roman Catholic church.

Since Éamon de Valera drew up the constitution of Ireland in 1937, believing that the Catholic church was central to Irish identity, nation and church have been inextricably linked. Now, with the people of Ireland voting to back abortion – and therefore rejecting the teaching of the Catholic church that is opposed to it – there has been a severing of that link. It is not the only place in Europe where the church is in trouble, for across the continent it has become caught up in different nations’ struggles over their identity.

Many people connected the referendum result in Ireland to the sex abuse scandals that have beset the church there in recent years and caused a loss of authority. While the scandals hastened an end to Catholic Ireland, it is not so clear that they caused it. Rather, it is Ireland’s reinvention of itself that led to this result. When the taioseach, Leo Varadkar, described the referendum result as a “quiet revolution”, he was borrowing a phrase first used about the province of Quebec. It, too, was once devoutly Catholic; it, too, has become remarkably secular in recent times. Both places have a history of being suppressed by the English. Quebec’s people once held on to their French tongue and heritage and their Catholic faith as expressions of being Québécois. But as Quebec province gained more autonomy and the Canadian government gave French equal status with English as the official language, so Catholicism became less prominent a part of Quebec’s identity. In Ireland, as relations with Britain improved, and the Troubles over the border waned, so the need to cleave to the church as part of Irish identity has declined.

For the Vatican, this severing of cultural ties may be at its most dramatic in Ireland and Quebec, but there has been decline in its power and influence elsewhere, particularly in western Europe. Last week, even in strongly Catholic Portugal, parliament voted to reject euthanasia – again opposed by the Catholic church – by a mere five votes. Personal morality and church teaching have been issues for Catholics since Pope Paul VI published his encyclical, Humanae Vitae, in July 1968, which banned artificial birth control. Many Catholics rejected such papal interference in the bedroom. Fifty years on from Humanae Vitae, Paul VI is to be made a saint.

Montreal’s stunning Notre Dame Basilica in once predominately Catholic Quebec. Photograph: Hemis/Alamy

Meanwhile, even in once staunchly Catholic nations such as Spain and Italy, birth rates have crashed and plenty of Catholic nations, including Ireland, back gay marriage. The ebb and flow of Catholic influence is having a profound impact on Europe. The European Union owes its origins not only to a desire for peace after two world wars, but also to the philosophy of its founding fathers, Jean Monnet and Robert Schuman, who took their thinking about subsidiarity and solidarity from Catholic social teaching. Now, even Italy appears disillusioned with the wider European project.

Much of that antipathy is due to the vast numbers of migrants and refugees, including Muslims, flocking across the Mediterranean from Africa and the Middle East. While Pope Francis has long spoken up for refugees – and took a refugee family of Muslims home to Rome with him after a visit to Lesbos in 2016 – his denunciation of what he calls the “globalisation of indifference” to the plight of desperate people has often been ignored. Instead, in many Catholic places, conservative politicians have suggested that migrants, especially Muslims, are a threat to traditional culture. In staunchly Catholic Poland, the Law and Justice party-led government has denied settlement to Muslim refugees, while Bavaria’s premier, Markus Söder, has decreed that the Christian cross should be erected at the entrance of all public buildings to reinforce Christian identity following the arrival of Muslim migrants. Catholic bishops have expressed strong disquiet about it.

Elsewhere, as secularisation has grown, so the church’s influence has waned. It has happened in Australia; even in the US, which remains a strongly Christian country, there has been a fall-off in mass attendance, but also reputational damage. Again, it has much to do with sex abuse scandals, including cover-ups by senior clergy. But the church cannot be written off. While the tide of faith has been ebbing for so many in the west, it still thunders on the shores of other parts of the world. It is strong in Latin America, thriving in Africa and growing in Asia.

Many people seem to make a distinction between the church, which they perceive as strongly authoritarian, and Francis, who remains highly popular with believers and non-believers who like his focus on mercy rather than rigid adherence to rules. In August, he is due to visit Ireland and it will be a moment for both church and people to think again about their relationship. Many people may consider the abortion vote a rejection of an oppressive, 1950s society, but if the new secular Ireland is stridently antipathetic to the church, then that is replacing one form of illiberalism with another.

For there is much to celebrate about the Catholic church that too many in Europe, including in Ireland, forget: it educates more girls than any other organisation in the world; its charity arm, Caritas, is the biggest global aid organisation after the Red Cross. In a world of consumerism, speed and relentless egotism, it proffers a spiritual alternative.

But the church has to find a way of existing in newly secular societies. Officials in Rome have told me they are fascinated by the example of Britain, where the church has learned to negotiate secular parameters. Typical of this were the comments of Cardinal Vincent Nichols, archbishop of Westminster, about the Irish vote. He made clear his concerns about abortion but also stressed that the church has to be consistently pro-life in action, including being “in support of women who are trapped in difficult and painful circumstances”.

Lack of such an empathetic tone has lost the church support elsewhere in secular Europe. Now it has to take the imaginative leap to find it. Listening to women – not always a strong point in an all-male priesthood – is a place to start.

• Catherine Pepinster is the author of The Keys and the Kingdom: The British and the Papacy