In 1987, the plain people of Ireland were asked in a referendum whether or not they wanted divorce to be made legal in their country. They overwhelmingly voted No. Hardly surprising, everyone said, since Ireland was the most Catholic country in Europe. No more.

The massive vote in favour of legalising gay marriage in the same country charted the profound transformation undergone by Irish society in a single generation.

In less than three decades, the Catholic Church has lost its grip on the Irish. From being one of Europe’s most socially conservative societies, Ireland has become the first country in the world to approve same-sex marriage – one of the modern world’s defining issues – not from the legislation of a parliamentary elite, but through a poll of the whole people.

The self-destruction of the institutional church has been spectacular. Revelations over the extent of sexual abuse by predatory priests have undermined the moral authority of the Catholic hierarchy and overturned the nearest thing Europe had to a theocracy. It was not just paedophile priests. Scandals involving regimes of physical and psychological cruelty have been laid bare involving nuns and religious brothers in schools, care homes and the infamous Magdalene laundries set up by the church for single mothers and “fallen women”.

Irish gay marriage vote results: In pictures Show all 11 1 /11 Irish gay marriage vote results: In pictures Irish gay marriage vote results: In pictures Drag queen Panti Bless and crowd celebrate a Yes victory Drag artist and Yes activist Panti Bliss joins supporters to celebrate in front of Dublin Castle Getty Images Irish gay marriage vote results: In pictures The celebrations started last night in Dublin and continued all day A couple celebrating in Dublin EPA Irish gay marriage vote results: In pictures A woman heading to the polling station yesterday Woman walks past a mural of two rainbow coloured hearts on polling day. Polling stations in the 43 constituencies across country opened their doors yesterday to vote on legalising same sex marriage EPA Irish gay marriage vote results: In pictures A 'Yes to Equality' badge A pro-gay marriage badge on a voter's lapel in gaelic meaning "Yes to Equality" seen in Dublin on polling day. EPA Irish gay marriage vote results: In pictures A cafe in Dublin lending its support to the cause Many businesses in Ireland have got involved in the campaign, declaring their support for both the Yes and No campaigns EPA Irish gay marriage vote results: In pictures Two campaign posters side by side posters on a Dublin street Both sides have campaigned fiercely saying they are fighting for social freedom EPA Irish gay marriage vote results: In pictures Newly married couple share their support for a Yes vote Newly married Anna and Vincent Fox share a kiss as they mark their support for a Yes vote in Dublin on polling day Getty Images Irish gay marriage vote results: In pictures 50 foot mural on the wall of Caherkinmonwee Castle in Galway to celebrate gay marriage A 50 foot referendum mural created by artist Joe Caslin to promote a Yes vote Getty Images Irish gay marriage vote results: In pictures Supporters celebrate an expected Yes vote Supporters in favour of same-sex marriage pose for a photograph as thousands gather in Dublin Castle Getty Irish gay marriage vote results: In pictures Couple waiting for the result in Dublin Castle Erin Reddy (left) and Dee Campell awaiting the result at Central Count Centre in Dublin Castle PA Irish gay marriage vote results: In pictures A gay marriage activist kisses her rosary beads in celebration A gay marriage supporter kisses her rosary beads at the Central Count Centre at Dublin Castle PA

Worse still was the evidence that bishops had sheltered these abusers for decades. The regimens of the abusive institutions were approved by the church hierarchy. They were often endorsed by government inspectors but, revealingly, the secular state has largely avoided the opprobrium which has attached to the church. That suggests that something more has been going on in Ireland than disillusion with Catholicism over abuse nurtured in the hothouse of clerical culture.

The Catholic Church was the single most powerful influence throughout the Irish Republic’s first 60 years. It shaped government policy through public pressure and clandestine consultations but primarily through the way it set the cultural, political and social norms of Irish society. For decades, its self-confident moral authority went unchallenged.

Looking back, the high point of its power was the few days in September 1979 when John Paul II became the first pope to visit Ireland. Then one in three of the Irish population congregated in Phoenix Park in Dublin to hear him say Mass. It was the biggest gathering of Irish people ever in one place – and the pinnacle of the influence of Catholicism on the Irish state.

But something else was at work in Irish society. Six years before the Pope arrived, Ireland had joined the EU, giving it access to markets much larger than previously when its trade had been predominantly with Britain. That, combined with an influx of foreign investment, transformed Ireland from one of the poorest countries in Europe to one of the wealthiest. Its economy grew so powerfully in the 1990s that Ireland became known as the Celtic tiger.

With that affluence, and an increased engagement with Europe, came a shift in social attitudes. Emigration, so long a potent norm in Irish society, fell away. Brighter and more enlightened Irish talent no longer looked abroad but remained at home and fostered change. The Economist named Ireland the best place to live in the world. “Rising material wealth seems to have expanded minds as well as wallets,” as one Irish commentator put it. Secularism became linked in the public imagination with the benefits of urban modernity and religion was relegated to an association with the poverty of the rural past.

The result comes little more than two decades after homosexuality was legalised in Ireland (Getty) (Getty Images)

Voices began to be raised in public for a liberalisation of laws on contraception, divorce and even abortion. If peace came dropping slow on the island of Ireland, social change was rapid. Restrictions on contraception were lifted. Though a referendum to legalise divorce was heavily defeated in 1986, it was passed in 1995. Homosexuality was decriminalised in 1993, albeit 30 years later than in the UK. A rift began to grow slowly and silently between the church and society.

It was, of course, the paedophile priests who sent that relationship into freefall. Sunday Mass attendance, which was more than 90 per cent in the 1970s, had fallen to 34 per cent by 2013. The Archbishop of Dublin, Diarmuid Martin, estimates that in the capital, the figure has plunged to only 18 per cent. Many in Ireland now describe themselves as “post-Catholics”. They are, according to Michael Kelly, the editor of The Irish Catholic newspaper, “functionally atheist”.

A stand-off developed between the Irish government and the church in the face of a continuing denial and lack of action on abuse by both the Irish bishops and Rome. The Irish prime minister said that an official state enquiry had “exposed the dysfunction, disconnection, elitism and narcissism” in the Vatican. Dublin dramatically broke off diplomatic relations with the Holy See for almost three years.

All of this explains why Archbishop Martin decided that the Catholic Church would not lead the opposition to a Yes vote on gay marriage in Friday’s referendum. He would vote No, he said, but added: “I have, however, no wish to stuff my religious views down other people’s throats.”

The tone of the bishop’s rhetoric was lowered extraordinarily. “Marriage isn’t just about two people falling in love. It’s a much more complex,” the Most Rev Martin said. “My voting No is not a vote against gay and lesbian people.” He carpeted one bishop who used more vivid and divisive language. The church had in the past treated gays and lesbians in a “harsh and hostile way”, he also said, leaving the opposition on the gay marriage vote to be led by groups of Catholic lay people.

But in the end, slogans from the No campaign such as “Two men can’t replace a mother’s love” could not prove enough to hold the day against an inexorable tide of change.