JERUSALEM >> Prime Minister Benjamin Netanyahu’s government today for the first time advanced a plan to overhaul the country’s legal system, defying a mass uproar among Israelis and calls for restraint from the United States.

The vote marked only preliminary approval for the plan. But it raised the stakes in a political battle that drew tens of thousands of protesters into the streets, sparked criticism from influential sectors of society and widened the rifts in an already polarized country.

The 63-47 vote after midnight gave initial approval to a plan that would give Netanyahu’s coalition more power over who becomes a judge. It is part of a broader package of changes that seeks to weaken the country’s Supreme Court and transfer more power to the ruling coalition.

Netanyahu’s ultrareligious and ultranationalist allies say these changes are needed to rein in the powers of an unelected judiciary. Critics fear that judges will be appointed based on their loyalty to the government or prime minister — and say that Netanyahu, who faces trial on corruption charges, has a conflict of interest in the legislation.

The showdown has plunged Israel into one of its most bitter domestic crises, with both sides insisting that the future of democracy is at stake in their Middle Eastern country. Israeli Palestinians, a minority that may have the most to lose by the overhaul, have mostly stayed on the sidelines, due to discrimination they face at home and Israel’s ongoing 55-year occupation of their Palestinian brethren in the West Bank.

The legislators cast their votes after a vitrolic debate that dragged on past midnight. During the session, opposition lawmakers chanted, “shame,” and wrapped themselves in the Israeli flag — and some were ejected from the hall.

Thousands were rallying outside the Knesset, waving Israeli flags and holding signs reading “saving democracy!” Earlier in the day, protesters launched a sit-down demonstration at the entrance of the homes of some coalition lawmakers and briefly halted traffic on Tel Aviv’s main highway.

Netanyahu accused the demonstrators of violence and said they were ignoring the will of the people who voted his coalition into power last November.

“The people exercised their right to vote in the elections and the people’s representatives will exercise their right to vote here in Israel’s Knesset. It’s called democracy,” Netanyahu said, though he left the door open for dialogue on the planned changes.

The vote on part of the legislation is just the first of three readings required for parliamentary approval, a process that is expected to take months.

Nonetheless, the opposition, including tens of thousands of protesters in front of the Knesset in Jerusalem and in Tel Aviv, saw Monday’s vote as the coalition’s determination to barrel ahead.

“We are fighting for our children’s future, for our country’s future. We don’t intend to give up,” said opposition leader Yair Lapid.

Israel’s figurehead president has urged the government to freeze the legislation and seek a compromise with the opposition, a position supported by most polls.