The Israeli government said it would amend adoption law in the country to give same-sex couples equal rights.

The state on Sunday made the announcement during a hearing at the Supreme Court in response to a petition regarding adoption by same-sex and common-law couples filed by the Association of Israeli Gay Fathers, with the Israel Religious Action Centre of the Reform movement, against the Social Affairs Ministry and the attorney general.

The state said it would introduce the new legislation by June 2018. The agreement comes less than a month after the Ministry of Welfare and Social Affairs reversed its opposition to allowing same-sex couples to adopt in the country. The government had initially told the court that given the “reality of Israeli society,” same-sex parents put an “additional burden” on their adopted children.

The agreement to introduce the new legislation led to the court dismissing the lawsuit, though the court reminded the two sides that if the legislation is not forthcoming, the petitioners could return to court.

“The court recognised the merits of the petition presented to them and decided to encourage a fundamental change in Israel’s adoption policy. From now on same sex families, who deserve the right to adopt like any other family, will have that right,” said Riki Shapira Rosenberg, lead attorney for the Israel Religious Action Centre, in a statement. “We will continue to closely monitor the legislative processes following the petition to ensure that the Government follows through on its commitment and soon.”

Although adoption by same-sex couples has been legal in Israel since 2008, in practice it has been nearly impossible. Because opposite-sex couples have been given priority, only three same-sex couples have adopted in Israel out of 550 applicants. More than 1,000 opposite-sex couples have adopted in the past nine years.