Ultra-Orthodox officials made a last-ditch effort on Wednesday to keep Immanuel parents from being arrested and jailed for refusing to implement a High Court of Justice ruling requiring Ashkenazi and Mizrahi girls to study in the same classes.

Thousands of people are expected to demonstrate in Jerusalem and Bnei Brak Thursday to support the right of Ashkenazi Hasidic parents to keep their children in segregated classes in Immanuel.

The 43 families of the Ashkenazi girls seemed elated Wednesday by the prospect of their impending arrest and two-week jail term, which some called "a historic stand for the sanctification of the name of heaven."

The police have given a permit for a 20,000-strong demonstration in Jerusalem, to be led by Ashkenazi Haredi political and religious leaders. The numbers could far exceed that figure, though, to judge by the calls issued by heads of yeshivas and schools to cancel classes today so students can attend the protest.

Even the spiritual leader of the Sephardi ultra-Orthodox Shas party, Rabbi Ovadia Yosef, has come out against the petitioners seeking integration. He said they should not have taken the matter to the courts.

Attempts to find a compromise were orchestrated Wednesday by former Shas chairman Aryeh Deri, who met in Jerusalem with the most prominent leader of the Ashkenazi community in the northern West Bank settlement of Immanuel - the Slonim grand rabbi, Shmuel Berezovsky.

Deri is focusing his efforts on assuring compliance with the 2009 High Court ruling requiring the ultra-Orthodox Beit Yaakov school in Immanuel to make sure the Mizrahi students study with their Ashkenazi peers. Most of the students are Ashkenazi.

The Ashkenazim have said they are not guilty of ethnic discrimination but are attempting to keep the Ashkenazi students from being influenced by those they consider to be less religious.

Some have been discussing the possibility of building another school in Immanuel for next year - the fourth for Haredi elementary-age girls - that would give parents the autonomy to decide who should study with whom. The High Court petitioners, chief among them Yoav Laloum, said they did not oppose the opening of another school, but the compromise has not really been embraced by all the parties involved.

Various political officials have been meeting in an effort to resolve the issue. MK Rabbi Moshe Gafni (United Torah Judaism ) met Wednesday with Prime Minister Benjamin Netanyahu and Justice Minister Yaakov Neeman. Deputy Health Minister Yaakov Litzman met with Education Minister Gideon Sa'ar, and Deputy Education Minister Meir Porush is expected to meet Thursday with President Shimon Peres to ask him to pardon the parents.

The State Prosecutor's Office might seek the arrest of only one parent rather than the whole group.

But even as politicians held talks in an effort to resolve the issue quietly, many Haredim were gearing up for the demonstration. On Wednesday, the Slonim beit midrash was full of people holding feverish conversations about Jews who died for the sanctification of God's name, mixed with stories from the High Court.

A briefing was held at the Slonim beit midrash Wednesday for the parents expecting to be arrested for contempt of court. "Tomorrow we'll all go to jail," Yitzhak Weinberg, a spokesman for the parents, said to applause.

Weinberg announced Thursday's protest schedule, including the busing of the Slonim Hasidim to Jerusalem to receive the grand rabbi's blessing, demonstrations and activities for the children of parents who are expecting to go to jail. The 43 sets of parents plan to appear in their Sabbath finery for the arrest.

The protest in Bnei Brak will begin at 1 P.M., where a representative of the parents from Immanuel will speak. The main march will begin an hour later in Jerusalem and will go to police headquarters in the Russian Compound. Dozens of the pro-segregation parents are to stand on the pedestrian bridge over Jerusalem's Bar Ilan Street wearing signs saying "prisoner sanctifying the name of heaven."

Ads to appear in newspapers on Thursday will call on people to avoid violence. Yerah Tocker, a spokesman for the protest, said "avoiding violence is one of the main emphases of the organizers."

"We want to protest the High Court ruling and declare that for all of us, in light of the ruling, Torah comes first," he said.

Despite the pledges of non-violence, police are to deploy in large numbers in Jerusalem, Bnei Brak, Beit Shemesh, Immanuel and near Ma'asiyahu Prison, where apparently the fathers of the girls are to be taken, and Neveh Tirza Prison, where the mothers are to go.

Police also called on drivers to avoid the area of the demonstrations in Jerusalem on Yermiyahu, Bar Ilan, Shmuel Hanavi and Hanevi'im streets, and in the Russian Compound.

The Courts Administration on Wednesday beefed up security around Supreme Court Justice Edmond Levy, who headed the panel that ruled against the segregation. Levy, who wrote the sole dissent from the anti-segregation ruling, came out strongly against parents seeking rabbinic advice on the ruling. "No ruling of a court in general, or the High Court in particular, requires the authorization of any person, not even halakhic (Jewish law ) authority," Levy said.

Wednesday for the first time since the segregation issue in Immanuel became public three years ago, Yosef said he was "very shocked" at the petition.

Shas chairman Eli Yishai  met on Wednesday with Yosef, after which he said Yosef was "pained at the discrimination and also at turning to the courts and the High Court ruling." He said it would have been better to deal with the issue "in pleasant ways" and insist on a solution out of court. Shas has not told its followers whether to take part in the demonstrations. However, this evening the Shas Council of Torah Sages is to hold a special meeting on the issue and will set its official position.

Rabbi Shimon Ba'adani is the spiritual leader of the Yemenite Jewish community in Immanuel, and all his daughters study in the Hasidic classes with mostly Ashkenazi girls.

The Shas position is very complex and not likely to win it many supporters in its community. One of the main reasons Shas has not expressed itself yet on the matter is because the elite Shas families, including the Yosef and Yishai families, send their girls to Ashkenazi schools.

Deri, a former Shas chairman, has been waiting a long time for the right moment to re-enter politics after serving time on corruption charges. On Wednesday he showed signs of moving in that direction. He told Haaretz the political system had to make decisions in the Immanuel affair and not let the courts intervene.

"The handwriting is on the wall. A terrible rift among the people," Deri said. "There are ministers and deputy ministers. They should get together and go to the prime minister's office and say, 'Let's solve the problem.'"

The Ashkenazi community is united in its support for the demonstration. Rabbi Shlomo Elyashiv announced he was personally going to join the demonstration, as did the Gerer rebbe and other leading rabbis.

The Immanuel affair is the most dramatic state-religion clash to break out here. It is now no longer about the length of skirts of Beit Ya'akov students, or the autonomy of the education system, but a fundamental question of identity: Who will be king? Who will decide? Even the petitioners, Mizrahi Haredim, felt uncomfortable on Wednesday with the frontal clash between religion and state.

No less important, Levy proposed to the parents on Tuesday to sit at the table with the Education Ministry regarding a new school next year for Immanuel. That was the first time the High Court sent a hint to all parties not to oppose the opening of a school with more autonomy, albeit less state funding. This may mean that, at least for now, Ashkenazi rabbis won't be instructing their followers to leave Immanuel.