By Padraic Halpin and Conor Humphries

DUBLIN (Reuters) - The people of Ireland backed same-sex marriage by a landslide in a referendum that marked a dramatic social shift in a traditionally Catholic country that only decriminalized homosexuality two decades ago.

After one of the largest turnouts in a referendum there, 62 percent of voters said 'Yes', making Ireland the first country to adopt same-sex marriage via a popular vote.

'Yes' supporters crowded into the courtyard of Dublin Castle to watch in blistering sunshine as results trickled in from around the country were shown on a large screen. They cheered with joy as the final tally was announced and then burst into a rendition of the national anthem.

"We woke up today to a new Ireland. The real Irish Republic that I have dreamed of my whole life," said Jean Webster, a 54-year-old administrator who came out as a lesbian eight years ago after separating from her husband.

Government ministers waved a rainbow flag from the stage in front of the crowd and one lesbian senator proposed to her partner live on national television.

"The answer is yes to their future, yes to their love, yes to equal marriage. That 'Yes' is heard loudly across the world as a sound of pioneering leadership from our people," Prime Minister Enda Kenny told a news conference. "Ireland, thank you."

The Catholic Church, which teaches that homosexual activity is a sin, saw its dominance of Irish politics collapse after a series of child sex abuse scandals in the early 1990s and limited its 'No' campaigning to sermons to its remaining flock.

The archbishop of Dublin said the result presented a challenge.

"It is a social revolution. It's very clear that if this referendum is an affirmation of the views of young people, then the Church has a huge task ahead of it," Archbishop Diarmuid Martin told national broadcaster RTE.

"The Church needs to do a reality check."

TABOO

Ireland follows several Western European countries including Britain, France and Spain in allowing gay marriage, which is also legal in South Africa, Brazil, Canada and some U.S. states, while homosexuality remains taboo and often illegal in many parts of Africa and Asia.

Story continues

U.S. Vice President Joe Biden tweeted: "We welcome Ireland's support for equality. #LoveWins"

After Irish expatriates flocked home to vote, 60 percent of registered voters cast their ballot, the highest in two decades.

"This is a big placard from the people of Ireland to the rest of the world saying this is the way forward," said David Norris, who began a campaign for gay rights in the late 1970s.

The proposal was backed by all political parties, championed by big employers and endorsed by celebrities, all hoping it would mark a transformation in a country that was long regarded as one of the most socially conservative in Western Europe.

Only a third of the country backed the decriminalization of gay sex for men over 17 in 1993, according to a poll at the time. When voters narrowly legalized divorce in 1995, only five of the 30 constituencies outside Dublin backed the proposal.

This time, all bar one of the 43 voting areas approved the marriage measure.

"It changes everything, the worries and fears I had as a young gay kid in Ireland, they're all gone," said Ger O'Keefe, 27, a 'Yes' campaigner from Waterford.

"This will tell kids now that you don't need to be afraid."

(Editing by Robin Pomeroy)