Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

The Israeli parliament voted late Monday to retroactively legalize several thousand Jewish homes built in the West Bank, a move that could complicate what had seemed to be a warming relationship with the United States.

But the measure still faces steep obstacles, including legal challenges that could land it before Israel's Supreme Court, where the attorney general has said he will not argue in defense of it.

Monday's contentious vote took place after Israel said it had started demolishing a small Jewish settlement deemed illegal by the Supreme Court because it was on private Palestinian land. Settlers and their supporters had been pushing the new legislation as a way to avoid similar rulings in other unauthorized communities built in occupied territory. But critics say the measure is illegal and would make peace with the Palestinians even more difficult.

Human rights groups reacted with outrage.

One, B'Tselem, called the vote a “disgrace” and accused lawmakers of “lending a semblance of legality to this ongoing act of plunder.” The organization also said the measure was “a slap in the face of the international community.”

Another, Yesh Din, called the measure and an overreach by the Knesset, the Hebrew name for Israel's parliament. “The landowners’ struggle will continue in court," the group said.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

Israeli Prime Minister Benjamin Netanyahu has already announced plans for an additional settlement, prompting a stern response last week from the Trump administration.

President Trump — considered more sympathetic to Jewish settlements than former President Barack Obama —warned Israel to stop the announcement of new settlements. The White House said new construction "may not be helpful" in achieving peace.

That admonishment marked the first public disagreement between Trump and Netanyahu, who plans to visit the White House Feb. 15.

Related: U.S. Warns Israel to Stop Announcing New West Bank Settlements.

Settlements are one of the most contentious issues between Israel and the Palestinians. About 600,000 Jewish settlers live in about 140 settlements built in the West Bank and East Jerusalem, areas captured in the Six-Day War of 1967.

Israeli Prime Minister Benjamin Netanyahu speaks to President Donald Trump during their meeting in New York on Sept. 25, 2016. Kobi Gideon/Government Press Office / Reuters

Much of the international community, including the United Nations and the European Union, consider the settlements to be an illegal taking of land envisioned as a future homeland for Palestinians.

For more than two decades, U.S. foreign policy has been pushing for a negotiated peace deal —a "two-state solution" — that would include the establishment of a Palestinian state alongside Israel.

Related: Israel Okays 2,500 New West Bank Settlement Homes

During his presidential campaign, Trump said peace between Israel and the Palestinians could be achieved only through direct negotiations, indicating that he believes Israel shouldn't be allowed to act unilaterally.

The White House said last month that Trump emphasized "the deep and abiding" partnership between the two countries and that he "affirmed his unprecedented commitment to Israel's security." Those statements fueled speculation that Israel’s hardline government would resume expanding settlements in Palestinian territory.

Related: Trump, Netanyahu Have 'Very Warm' Conversation

Netanyahu himself said last month that Trump's election presents "significant opportunities" for Israel.