Bermuda has forbidden same-sex marriage, only nine months after legalizing it, in what advocates for gay and lesbian rights called a disappointing setback.

Same-sex marriage became legal in Bermuda, a British overseas territory, in May as a result of a ruling by the island’s Supreme Court.

But the unions are unpopular with some voters.

In 2016, Bermudians voted against same-sex marriage in a referendum, and after the court ruling in May, the territory’s legislature drafted a bill banning same-sex marriage but giving all couples legal recognition as domestic partners. Parliament adopted the Domestic Partnership Act in December, and on Wednesday the territory’s governor, John Rankin, signed it into law.

The British prime minister, Theresa May, said Britain was “seriously disappointed,” but the Foreign Office said on Thursday it would be inappropriate to block the measure.