SAN JUAN, Puerto Rico — Puerto Rico’s Justice Department announced Friday that it will not defend the U.S. territory’s laws banning gay marriage in a major turnaround for the socially conservative island that surprised many.

Justice Secretary Cesar Miranda said the government can no longer continue to discriminate against the gay community.

“It’s neither fair nor correct to defend the constitutionality of that law,” he said. “Same-sex couples cannot get married and therefore do not have access to those rights. They should be available to all those who love each other, who take care of each other, who work and contribute to this society like everyone else.”

The announcement comes a year after several gay couples in Puerto Rico filed a lawsuit challenging the constitutionality of Puerto Rican laws that define marriage as between a man and a woman, as well as those that prohibit same-sex marriage and the recognition of such marriages.

The territory’s Justice Department had defended the laws before a federal judge who upheld them, but the case has been appealed to the 1st U.S. Circuit Court of Appeals in Boston, and Miranda said the department will no longer intervene.

Hundreds celebrated the news in Puerto Rico.

Miranda made the announcement a week after a group of legislators from Gov. Alejandro Garcia Padilla’s party said they supported gay marriage.

While the governor has repeatedly stated that he is not in favor of gay marriage, he said he supports the change.

“Everyone knows my religious beliefs, but it’s not up to political leaders to impose our creeds,” he said. “We have to push for the progress of civil and human rights under equal conditions for everyone.”

Opposition lawmakers and religious leaders criticized Friday’s announcement and accused Garcia of imposing changes instead of consulting with the public and holding a referendum.