Portugese politicians have granted legal rights and tax benefits to gay and lesbian couples who have lived together for more than two years.
Homosexual couples will be allowed the same rights as heterosexual couples in common law marriages.
The bill has passed on the votes of a majority of left-of-centre politicians in the 230-seat National Assembly, Portugal's parliament, while right-of-center parties opposed the bill.
Gay and lesbian groups in Portugal have lobbied for several years for equal rights with common law couples of different sexes.
In 1999 a majority of politicians, including some from the governing left-of-centre Socialist Party, balked at a proposal to incorporate same-sex relationships in new legislation on common law marriages.
However changes to the bill, including a deal on taxes, persuaded more Socialists to approve it.
Homosexual marriages are not permitted in the mostly Roman Catholic country.