MONTEVIDEO (Reuters) - Uruguay’s Congress legalized civil unions for homosexual couples on Tuesday in the first nationwide law of its kind in Latin America.

Under the new law, gay and straight couples will be eligible to form civil unions after living together for five years. They will have rights similar to those granted to married couples on such matters as inheritance, pensions and child custody.

Uruguay’s Senate passed the bill unanimously after the lower house approved it last month, a congressional spokesman said. The country’s center-left president is expected to sign it into law.

Several cities, including Buenos Aires and Mexico City, already have gay civil union laws on the books. Uruguay’s law would be the first nationwide measure in Latin America, which is home to about half the world’s Roman Catholics.

In Uruguay, couples must register their relationship with authorities to gain the cohabitation rights, and they will also be able to formalize the end of a union.

Gay marriage remains illegal in Uruguay, a small South American country known for its secular streak.

The Catholic Church has said its opposition to gay marriage is non-negotiable and Catholic politicians have a moral duty to oppose it.

Earlier this year in Colombia, a group of senators shot down a landmark gay rights bill at the last minute, using a procedural vote to back away from the measure.