Israel's Supreme Court ruled against a surrogacy law Thursday that critics said discriminated against same-sex couples and which sparked uproar in the LGBT community when it was passed.

In a statement, the court said the 2018 law, which expanded access to surrogacy in Israel to single women but excluded gay couples, “disproportionately harmed the right to equality and the right to parenthood” for same-sex couples and that it was unlawful. It gave the state a year to change the law.

Israeli same-sex couples looking to become parents are often deterred by the additional costs that come with finding a surrogate in another country, costs they could save if they were allowed to use a surrogate in Israel.

“This is a historic decision for Israel, for the gay community and for thousands of Israeli couples who will fulfill their basic right to become parents,” said Hila Peer, head of The Aguda-The Association for LGBTQ Equality in Israel.

The state had argued that the law was intended to protect surrogate mothers but the court ruled that it would be possible to strike a balance that would not discriminate.

The law's passage prompted tens of thousands of LGBT members and their families to protest, with many leaving work to demonstrate on the streets of Tel Aviv, Israel's liberal bastion, and elsewhere.

The protest generated widespread support and hundreds of employers said they would allow employees to observe the strike without penalty.

Israel has emerged as one of the world’s most gay-friendly travel destinations in recent years, in sharp contrast to the rest of the Middle East where gays are persecuted and even killed. Tel Aviv holds a raucous yearly pride parade which draws tens of thousands of revelers.

Gays serve openly in Israel’s military and parliament, and many popular artists, entertainers as well as the country's current justice minister are openly gay.

However, leaders of the gay community say Israel still has far to go in promoting equality. Many saw the 2018 law as a betrayal by Israeli Prime Minister Netanyahu who said he would support an amendment that would include gay couples but then reneged under pressure from his ultra-Orthodox coalition partners.