South Africa's highest court on Thursday recognized the marriage of two Pretoria women and gave Parliament a year to extend legal marital rights to all same-sex couples.

The ruling, greeted with jubilation by gay men and lesbians but with frustration by some church leaders, will make South Africa the first country to allow marriages between gay people on a continent where homosexual activity is widely condemned and often outlawed.

Only four countries in the world -- the Netherlands, Belgium, Spain and Canada -- currently allow same-sex marriages nationwide. Several others, mostly in Europe, recognize civil unions between gay partners.

"I'm ecstatic," said Marie Fourie, 54, speaking by phone from Pretoria after the ruling by South Africa's Constitutional Court. "It is wonderful for the gay society."

Fourie married Cecelia Bonthuys, 44, on Dec. 11, 2004, a decade after they began living together and several weeks after they won the right to wed from the nation's second-highest court. But after the ceremony, officials in the government's Department of Home Affairs refused to recognize their union and appealed the decision to the Constitutional Court, the nation's highest.

That appeal resulted in Thursday's 111-page opinion giving the government a year to begin treating such unions in the same way as those between men and women.

Fourie predicted the change would lead to declines in what many gay leaders said was persistent discrimination, while also giving same-sex couples the same rights as heterosexual couples, such as the right to open joint bank accounts and visit each other as family members in hospitals.

"There's always remarks," said Fourie, who recalled often being addressed by a slur in the Afrikaans language for gay men and lesbians. "You learn to live with it. But after today, I think they will swallow all that."

The court's judges unanimously agreed that South Africa's 1996 constitution, which prohibits discrimination based on sexual orientation, guarantees the right of gay men and lesbians to marry. One justice, in a limited dissent, argued that the law should be overturned immediately rather than within a year.

That delay upset some activists, but both supporters and opponents of the ruling agreed there would be no way for Parliament to avoid approving the required amendments to the law.

"We have to accept that," said Efrem Tresoldi, a spokesman for the Southern African Catholic Bishops' Conference, speaking from Pretoria. He added that the church would continue to lobby against same-sex marriages on moral grounds.

"The church respects that people have certain sexual orientations, but we will never accept speaking in the same breath of same-sex unions and heterosexual marriage," Tresoldi said.

Word of the ruling raced through the nation's tight-knit community of gay rights activists, who saw the case as crucial to curbing discrimination. One serious abuse, they said, is the rape of lesbians and even some gay men in a misguided effort to change their sexual orientation.

"It's really, really difficult to be black and a lesbian in South Africa," said Thuli Madi, director of Behind the Mask, a Web-based magazine focused on gay life and issues. "As a woman, you are constantly harassed by the males in your community."

Elsewhere in Africa, attitudes are even more harsh. Gay and lesbian sex is illegal on most of the continent, with the death penalty a possibility in some cases. Many religious and political leaders call homosexuality un-African.

In Nigeria, opposition to same-sex marriage is so passionate that Anglican leaders have broken off relations with their counterparts in Canada over the issue. Nigerian President Olusegun Obasanjo said last year that homosexuality was "unbiblical, unnatural and definitely un-African."

On Thursday, some South African religious leaders criticized the ruling, but reaction was generally muted. The South African Council of Churches said it provoked such diverse reactions that the body was unlikely to have a unified position.

Ray McCauley, a well-known pastor, said he believed most South Africans did not agree with the decision.

"It is a sad day for South Africa when the very bedrock foundation of society, the family, is redefined by a court," McCauley said, according to the South African Press Association. "This ruling totally undermines marriage as we know it and the cherished formation of healthy, loving families."

No law in South Africa has prohibited gay men and lesbians from holding weddings and living as spouses. Many have signed contractual agreements stipulating joint ownership of property or distribution of assets after death.

But they still run into barriers when seeking to open joint checking accounts or visit each other in hospitals. More broadly, activists said, the prohibition against marriage made them second-class citizens.

"I'm not really sure I want to get married," said Glenn de Swardt of the Triangle Project, a gay and lesbian rights group in Cape Town, speaking by phone. "We want it because it will give us an equal opportunity. Whether I want to access that choice is a different thing."

The romance between Fourie, a carpet cleaner, and Bonthuys, a nurse, began after the two neighbors each discovered the other was a lesbian, Fourie said. They bought a house together and lived as a couple, deciding to have a wedding only after the first ruling, in November 2004.

They exchanged vows in the church of Andre Muller, a gay pastor driven from the Dutch Reformed Church.

"In the past, gay people have always been ridiculed, belittled," Muller said from Pretoria. "Now that this ruling has come, they are on an equal footing. Justice has been done."