The South African parliament passed legislation recognizing gay marriages Tuesday in an unprecedented move on a continent where homosexuality is taboo.

African National Congress veterans heralded the Civil Union bill for extending basic freedoms to everyone and equated it with liberation from the shackles of apartheid.

The bill's supporters had to overcome criticism from both traditionalists and gay activists and warnings that the legislation may be unconstitutional.

"When we attained our democracy, we sought to distinguish ourselves from an unjust painful past, by declaring that never again shall it be that any South African will be discriminated against on the basis of color, creed culture and sex," Home Affairs Minister Nosiviwe Mapisa-Nqakula told the National Assembly.

But a Christian lawmaker, Kenneth Meshoe, said it was the "saddest day in our 12 years of democracy" and warned that South Africa "was provoking God's anger."

One Church leader in Nigeria denounced the move as "satanic," reflecting the views on a deeply conservative continent where some countries are debating constitutional amendments to ban same-sex marriages.

But gay rights groups in Europe hailed South Africa as a shining example of progressiveness.

The National Assembly passed the Civil Union Bill, worked out after months of heated public discussion, by a vote of 230 to 41 with three abstentions. The outcome was expected given the ANC's huge majority. It now has to be approved by the National Council of Provinces, which is expected to be a formality, before being signed into law by President Thabo Mbeki.

The bill provides for the "voluntary union of two persons, which is solemnized and registered by either a marriage or civil union." It does not specify whether they are heterosexual or homosexual partnerships.

But it also says marriage officers need not perform a ceremony between same-sex couples if doing so would conflict with his or her "conscience, religion and belief."

South Africa recognized the rights of gay people in the constitution adopted after apartheid ended in 1994 -- the first in the world to prohibit discrimination on the basis of sexual orientation.

The bill was drawn up in order to comply with a Constitutional Court ruling last December that said existing marriage legislation was unconstitutional, as it discriminated against same-sex couples.

The court gave the government a Dec. 1 deadline to change the laws, saying that otherwise same-sex marriages would be legalized by default.

"In order to give effect to the Constitutional Court ruling, same-sex couples have to be allowed to marry so that they can enjoy the status, obligations and entitlements enjoyed at the moment by opposite sex couples," Mapisa-Nqakula said.

The Roman Catholic church and many traditional leaders objected to the use of "marriage" saying this denigrated the sanctity of traditional marriages.

In an effort to ease some of these concerns, the drafters of the bill allowed both religious and civil officers to refuse to marry same-sex couples.

Gay rights groups criticized this "opt-out" clause, saying they should be treated the same as heterosexual couples.

But in general, they hailed the new measure.

"It demonstrates powerfully the commitment of our lawmakers to ensuring that all human beings are treated with dignity," said Fikile Vilakazi of the Joint Working Group, a national network of 17 gay and lesbian organizations.

In Africa, homosexuality is still largely taboo. It is illegal in Zimbabwe, Kenya, Uganda, Nigeria, Tanzania, Ghana and most other sub-Saharan countries. Even in South Africa, gays and lesbians are often attacked because of their sexual orientation.

Denmark in 1989 became the first country to legislate for same-sex partnerships and several other European Union members have followed suit. In the United States, only the state of Massachusetts allows gay marriage, Vermont and Connecticut permit civil unions, and more than a dozen states grant lesser legal rights to gay couples.