JERUSALEM — Prime Minister Benjamin Netanyahu was formally charged with bribery, fraud and breach of trust on Thursday, making him the first Israeli premier to be indicted while in office and sending Israel’s already stalemated political system into further disarray.

Israeli Attorney General Avichai Mandelblit capped almost three years of investigation and months of speculation by issuing a 63-page indictment against the country’s longest-serving prime minister and its center of political gravity for the last decade.

The cases against Netanyahu center on allegations that the prime minister and his wife, Sara, accepted more than $260,000 worth of luxury goods in exchange for political favors and that Netanyahu interceded with regulators and lawmakers on behalf of two media companies in exchange for positive news stories.

Netanyahu, 70, has steadfastly denied wrongdoing during a wide-ranging probe that he has dismissed as a politically motivated “witch hunt.”

In October, the prime minister’s legal team spent four marathon days in front of prosecutors arguing that the charges should be reduced or dismissed, an effort that apparently had little effect.

“I made this decision with a heavy heart but with a whole heart and a sense of commitment to the rule of law,” Mandelblit said at a news conference aired live on Israeli television. “Law enforcement is not a discretionary matter. It is an obligation that is imposed on us. It is my duty to the citizens of Israel to ensure that they live in a country where no one is above the law and that suspicions of corruption are thoroughly investigated.”

Few here expect the pugnacious prime minister to do anything ­other than ferociously fight the counts that emerged. Many predict he will seek a vote in parliament granting him some measure of immunity.

In a combative address Thursday night, Netanyahu called the indictment “a coup attempt” driven by a corrupt set of prosecutors. He demanded that an independent body review the prosecution. “It’s time to investigate the investigators,” he said.

“I give my life for our country. I fought for this country; I was injured for this country. I have been fighting for this country in recent years, both on the international stage and here in order to make us a global force. And I am very proud of our achievements,” Netanyahu said. “This is a very difficult day for me and those who support me.”

Of immediate concern is how the indictment will scramble his position in Israel’s chaotic political standoff.

“We are in a historical and unprecedented situation with new legal questions almost every day,” said Suzie Navot, a professor of constitutional law at the Haim Striks Law School in Rishon LeZion.

The indictment came on the first day of an unparalleled phase in Israeli politics: a 21-day window in which any member of parliament can try to form a governing majority. Netanyahu and his rival Benny Gantz both failed at that task in recent weeks. If no one succeeds, Israel would head back to national elections for the third time in 12 months.

While the law allows an indicted prime minister to remain in office until he or she is convicted and has exhausted all appeals, it is unclear whether Netanyahu remains eligible to present a proposed ruling coalition to Israel’s president.

“This is a question that will be brought to the Supreme Court of Israel,” Navot said. “I can imagine they will say the president does not have to give the mandate to an indicted member of the Knesset, that he can choose to give it to another member of the same faction.”

Several lawmakers said they would immediately petition the Supreme Court to have Netanyahu removed from office. In Jerusalem, protesters on both sides faced off outside the prime minister’s residence Thursday night.

The day’s news marked a stunning — and ignominious — moment in the remarkable career of “King Bibi.” Netanyahu has dominated Israeli politics in recent years like few other leaders before him.

Political observers have marveled at his powers of survival in the rough-and-tumble of Israel’s fractious party system and his ability to wield the levers of government to his own advantage.

But after two officials Netanyahu appointed became instrumental in the corruption investigation — Mandelblit, his former cabinet secretary, and former Israeli police chief Roni Alsheich — Netanyahu’s powers to ward off threats seem diminished.

“It shows that he’s not as omnipotent as everyone thought,” said Anshel Pfeffer, a Haaretz columnist who wrote a recent biography of the prime minister. “It shows the system is stronger than Netanyahu.”

In the first of the three cases, in which he is charged with breach of trust and fraud, police say the Netanyahus accepted more than a quarter of a million dollars in jewelry, cigars and other gifts from wealthy benefactors who had official business with the government. Among them was the ­Israeli-born film producer Arnon Milchan, whose credits include “Fight Club” and “Pretty Woman.”

Netanyahu also allegedly pressed the United States repeatedly to give Milchan a U.S. visa and, in Israel, pushed the finance minister to extend an income tax exemption that would benefit the producer. That also produced indictments for breach of trust and fraud.

The most serious charge, bribery, stemmed from another case arising from a period in which Netanyahu served as his own minister of communications. He allegedly intervened to smooth the way for a merger sought by Shaul Elovitch, then the majority shareholder of Bezeq, the country’s largest telecommunications company, in exchange for favorable coverage on the popular news website Walla, also owned by Elovitch. Walla reporters and editors have described being ordered to spike stories, tweak headlines and change photographs in ways that boosted Netanyahu’s image.

Elovitch and his wife, Iris, were also charged with bribery, obstruction of justice and suborning a witness in the investigation. Their lawyers issued a statement denying the allegations.

It is unclear how the charges will affect Netanyahu’s political standing. He would remain eligible to run in a possible third election next spring. (Only those convicted of a crime involving moral turpitude are barred from the ballot). But even the threat of indictment has been a major issue in the two previous campaigns. Gantz, who built his own campaign around a pledge not to serve with an indicted premier, issued a one-sentence statement Thursday: “This is a very sad day for the State of Israel.”

One October poll showed that a small majority of Israelis, 53.5 percent, thought Netanyahu should resign if indicted. Almost half, 47 percent, of his core right-wing supporters thought the same.

“Among Likud members and the right wing there is deep distrust for the legal process,” said Tal Schneider, a diplomatic and political correspondent for the Israeli business newspaper Globes. “Likud is backing him up because they have convinced themselves that it’s all a witch hunt, and we hear the same things from D.C. about Trump.”

Gadi Taub of the Federmann School of Public Policy at Hebrew University, also compared the unfolding drama in Jerusalem to the impeachment hearings in Washington.

“The difference is that the impeachment is a political process, whereas in Israel, the prosecutor is also the legal adviser to the government, which is absolutely ridiculous,” Taub said.

Many will be watching Netanyahu’s Likud party for signs that the indictments will weaken what has been his formidable grip on it.

Netanyahu was first elected as Likud chairman in 1993, serving in the opposition until 1996. He resigned from politics after being defeated in a general election in 1999, returning to lead the party in 2005. Since then he has consolidated his position in Likud, dividing and weakening his opponents and facing very few challenges over the years.

On Thursday, there were already indications that a leadership challenge was underway inside Likud.

Speaking at a diplomatic conference, former Likud minister Gideon Sa’ar said holding elections for a new party leader, especially if the country were forced into a third election, was “the right and necessary thing to do under the current circumstances.”

“First of all, that is what our constitution requires if we are about to have new elections,” he said. “We are a democratic party, and we haven't had primaries for several years already.”

Sa’ar said that he supported the prime minister’s efforts to form a national unity government, but “if we do go to elections, it is not reasonable to think that he will be successful in forming a government after third elections.”

He added, “I think I will be able to form a government, and I think I will be able to unite the country and the nation.”