Israel's High Court has ordered changes to the route of the West Bank barrier, to alleviate Palestinian suffering.
More than 20 other cases objecting to the route have yet to be decided
It said the route around Jerusalem must be changed, even if that meant less security for Israel.
Israel said it would comply with the court's decision, while Palestinian officials said the ruling did not go far enough.
The BBC's Barbara Plett in Jerusalem says the ruling sets a precedent for other legal disputes about the barrier.
Israel says the barrier is necessary to keep out suicide bombers; Palestinians call it a land grab that divides people from their families, jobs and schools.
The decision comes before a non-binding ruling by the United Nations' top court on the legality of the controversial network of fences and walls, planned to extend for 640km (400 miles) through occupied territory.
Divided by West Bank barrier
The International Court of Justice, which was asked to examine the issue last December amid mounting international concern, has said it will release its findings on 9 July.
The landmark ruling by the High Court affects a 30km (19-mile) section of the barrier to the north and west of Jerusalem.
The three-judge panel decided the government had the right to build the barrier and that construction was permissible on occupied land, but that an alternative route was possible.
"The route disrupts the delicate balance between the obligation of the military commander to preserve security and his obligation to provide for the needs of the local inhabitants," said the ruling from Chief Justice Aharon Barak and Justices Mishael Heshin and Eliyahu Matza.
"The route that the military commander established for the security fence... injures the local inhabitants in a severe and acute way while violating their rights under humanitarian and international law."
Israel's defence ministry said it would comply with the ruling and a new route would be drawn up "based on the principles set by the Supreme [High] Court, namely the proper balance between security and humanitarian considerations".
Barrier 'should go'
Palestinian Prime Minister Ahmed Qurei said the ruling was inadequate and insisted that the whole barrier should be torn down.
"It's a racist separation wall and therefore it should fall. There is no other alternative," he said.
The case was launched by Palestinian residents who said the barrier would disrupt the lives of 45,000 people in 10 villages by cutting them off from farms, schools and jobs.
Mohammed Dahla, a lawyer representing the Palestinians, hailed what he called a "courageous and very important" decision.
"This decision is more important than the one at The Hague because this one will be followed," he said outside the court.
"It says what we said from the beginning, that the building of the wall as it is being built is illegal and that there is another way to build it that will give security to Israel but won't violate Palestinian rights."
The decision sets a precedent for cases in more than 20 other petitions against sections of the barrier which have either been built or are planned.