South Africa's parliament has voted to legalise same-sex weddings - the first African country to approve such unions.
Gay rights activists complained about the existing law
The controversial Civil Union bill was passed by 230 votes to 41.
The legislation was introduced after the Constitutional Court ruled last year that the existing laws discriminated against homosexuals.
The ruling African National Congress ordered all MPs to turn up and vote for the bill, despite the opposition of church and traditional leaders.
The bill provides for the "voluntary union of two persons, which is solemnised and registered by either a marriage or civil union".
The existing Marriage Act defines a marriage as a "union between a man and a woman".
During the debate before the vote, Home Affairs Minister Nosiviwe Mapisa-Nqakula told MPs: "In breaking with our past... we need to fight and resist all forms of discrimination and prejudice, including homophobia."
But, Cardinal Wilfrid Napier, president of the South African Catholic Bishops' Conference, said the bill would be a blow against democracy.
"The impression we got is that there is overwhelming opposition to this bill from people throughout South Africa," he told South Africa's Daily News before the vote.
African Christian Democratic Party leader Reverend Kenneth Meshoe told MPs that those who voted for same-sex marriages would face divine wrath.
However, some gay rights activists have also criticised the bill, because it gives officials the right not to perform same-sex wedding ceremonies if this would conflict with their "conscience, religion and belief".
In the face of such strong feelings, the ANC had issued a three-line whip, instructing all MPs to vote in favour of the bill.
The ANC has a huge majority in parliament.
Last year, the Constitutional Court gave the government until 1 December 2006 to legalise same-sex weddings, after gay rights activists took the issue to court.
The ruling was based on the constitution, which was the first in the world specifically to outlaw discrimination on the grounds of sexual preference.
This is unusual in Africa where homosexuality is largely taboo - notably in its neighbour Zimbabwe.