Settler leaders accepted the government’s offer Tuesday night to willingly evacuate five buildings in the Givat Ulpana neighborhood of the West Bank settlement of Beit El, in exchange for 300 new housing units to be built in another part of the settlement.

The agreement comes after 10 days of negotiations between the residents’ representatives and government officials.

A central figure in the negotiations was Beit El yeshiva chief Rabbi Zalman Baruch Melamed, who said Tuesday that there was no “perfect solution.”

“This is a very difficult dilemma and any decision will be difficult and painful,” he said.

Israel Radio reported that Prime Minister Benjamin Netanyahu is expected to present the agreement to the newly-formed Ministerial Committee on Settlement Affairs on Wednesday.

On Wednesday, Sephardi Chief Rabbi Shlomo Amar praised the agreement. In an interview on the Voice of Israel, Amar said that in spite of the importance in Jewish law of settling the Land of Israel, the leaders of Beit El made the correct decision that will prevent a civil war.

The Supreme Court ruled earlier this year that the contested buildings in Givat Ulpana were built on private Palestinian land. The Court ordered their demolition by July 1.