Ireland has become the first country in the world to approve gay marriage by referendum with an overwhelming 62 percent "Yes" vote, further denting the once all-powerful Irish Catholic Church.

Supporters packed into the grounds of Dublin Castle hugged, kissed and waved rainbow flags in a festival atmosphere as the result was announced, and parties in the capital's gay bars went on into the night.

The constitutional change allowing same-sex marriage was passed with only 38 percent voting against it. All of Ireland's 43 constituencies except one voted in favour of the measure.

"Today Ireland has made history - the first country in the world to vote for equal marriage," Prime Minister Enda Kenny told reporters.

"With today's vote we have disclosed who we are: a generous, compassionate, bold and joyful people. Yes to inclusion, yes to generosity, yes to love, yes to equal marriage," he said.

The voter turnout was 60 percent - much higher than in other recent referendums.

As she swept into the castle party in high heels, Rory O'Neill or "Panti Bliss", Ireland's foremost drag queen and a leading "Yes" campaigner, declared: "It's an amazing day to be Irish!"

Outside the main counting centre in Dublin, Grainne O'Grady, 44, and Pauline Tracey, 53, said the plan was to "celebrate, celebrate, celebrate".

"I'm just so happy I could burst. We were voting on whether we were equal in our own country," said O'Grady, wearing a "Yes Equality" T-shirt.

Celebrities and political leaders tweeted congratulations and US Vice President Joe Biden, who is of Irish descent, wrote: "We welcome Ireland's support for equality. #LoveWins."

The referendum asked voters whether or not they approved the statement: "Marriage may be contracted in accordance with law by two persons without distinction as to their sex."

Legalising gay marriage is a seismic change in Ireland, where the Roman Catholic Church has traditionally been a powerful force.

Homosexuality was illegal until 1993 and abortion is still banned except where the mother's life is in danger.

'Reality check' for church

Al Jazeera's Tim Friend, reporting from London, said this was a significant vote considering the power and reach of the Irish Catholic Church.

"Church leaders across the world will be looking closely at the results of Ireland's referendum," he said.

The Archbishop of Dublin Diarmuid Martin told national broadcaster RTE that the Catholic Church now needed a "reality check".

"I think the Church needs to do a reality check right across the board... Have we drifted away completely from young people?" he said.

"It's a social revolution," said the archbishop, who had called for a "No" vote arguing that gay rights should be respected "without changing the definition of marriage".

The Catholic Church campaigned strongly for a "No" vote, insisting marriage can only involve a man and woman, drawing support from many older voters.

The majority of Irish people identify themselves as Catholic, but the church's influence has waned in recent years amid growing secularisation and after a wave of child sex abuse scandals.

All Ireland's main political parties supported amending the constitutional definition of marriage.

A string of Irish celebrities had also backed the "Yes" campaign including singer Sinead O'Connor, actor Colin Farrell and rock band U2, who posted a photo on Instagram with the words "In the name of love..." - one of their most famous songs.

The issue has drawn intense interest on social media under the hashtag #MarRef and was one of the most popular trending subjects worldwide on Twitter Saturday.

Many young Irish voters posted selfies of themselves returning from overseas by plane and ferry to vote in favour of gay marriage in Friday's referendum.