Israeli police have recommended indicting Prime Minister Benjamin Netanyahu in a pair of corruption cases, escalating a legal and political showdown that threatens to end the career of one of the longest-serving leaders in Israel’s history — and potentially send President Trump’s closest Mideast ally to prison.

Netanyahu has outlasted two American presidents, weathered the fallout from a bloody and inconclusive war in the Gaza Strip, and navigated Israel’s notoriously vicious political system so effectively that he’s on the verge of becoming his country’s longest-serving leader.

Now he faces the biggest challenge of his career. If Israeli Attorney General Avichai Mandelblit accepts the police’s recommendations, Netanyahu would be formally charged with bribery, fraud, and abusing the powers of his office; a conviction would almost certainly send him to prison.

The first case, known as Case 1,000, revolves around tens of thousands of dollars’ worth of jewelry, cigars, and other gifts that Netanyahu and his wife, Sara, allegedly received from wealthy businessmen — including an Australian, James Packer, who was once married to Mariah Carey — in exchange for political favors. (Israeli police are also reportedly close to recommending criminal charges against Sara Netanyahu.)

The second, known as Case 2,000, alleges that Netanyahu told Arnon Mozes, the publisher of Israel’s largest newspaper, that he’d support legislation designed to hurt Mozes’s main competitor in exchange for positive press coverage. According to transcripts obtained by Israel’s Channel 2, the two went so as far as to discuss potential pro-Netanyahu columnists that Mozes would hire.

On Tuesday, Netanyahu denied any wrongdoing and promised to remain in office. But that ultimately may not be up to him: The Israeli leader has a long list of enemies inside his own ruling Likud Party, and formal criminal charges could pave the way for one of Netanyahu’s Likud rivals to attempt to oust him from his position. Alternatively, the parties in Netanyahu’s fragile coalition government could pull out, spurring new elections that result in the leader of a different party being elevated to prime minister.

Netanyahu’s departure would reshape Israeli politics, but the full impact would extend far outside the country’s borders. Trump has an exceptionally close relationship with Netanyahu — the Israeli leader has effusively praised Trump in emoji-laden tweets — and recently handed Netanyahu a major political win by recognizing Jerusalem as Israel’s capital and promising to move the US Embassy from Tel Aviv to Jerusalem.

Trump has also signaled a potential willingness to tear up the Obama administration’s landmark nuclear deal with Iran, an agreement Netanyahu has been working to unravel since before it was even formally signed.

All of which is to say there’s a lot riding on whether the Israeli attorney general decides to go through with indicting Netanyahu. To understand what might be coming, it’s important to first understand what’s brought us to this point.

These are the cases that could take down Israel’s prime minister

Writing for Vox in March, Noam Sheizaf noted that every Israeli prime minister since Yitzhak Rabin and Shimon Peres, who served in the mid-1990s, has at one time or another faced criminal investigations while in office. Only one has been charged and convicted: former Prime Minister Ehud Olmert, who is serving an 18-month sentence in the same prison where former Israeli President Moshe Katsav spent five years following a rape conviction.

The potential new charges against Netanyahu come after years of controversy over his and his wife’s lavish spending (including shelling out $2,700 a year for gourmet ice cream), close relationships with Israeli and foreign business tycoons, and efforts to muzzle Israel’s left-leaning press to ensure warmer media coverage.

Now, Netanyahu faces formal criminal charges in two separate investigations.

In the first, “Case 1,000,” police say Netanyahu took, and at times demanded, expensive gifts from wealthy businessmen like Packer and Hollywood producer Arnon Milchan. In one incident reported by the Israeli media, Sara Netanyahu specifically demanded $2,700 worth of jewelry, which Milchan provided. According to a report in Haaretz, Milchan told police that the Netanyahus’ demands made him “feel sick.”

The second case, Case 2,000, is sordid in a very different kind of way. It stems from recorded conversations between Netanyahu and Mozes, the publisher of the Israeli daily newspaper Yedioth Ahronoth and the popular Ynet News website. As Sheizaf explains:

In their conversations, which took place before the 2015 Israeli elections, Mozes reportedly offered to do “everything in his power” to help Netanyahu stay in power “for as long as you want.” In exchange, Mozes requested legislation that would limit the ability of his main competitor, the pro-Netanyahu Israel HaYom newspaper, to distribute free papers.

Israel HaYom is owned by Sheldon Adelson, a billionaire GOP donor who contributed huge amounts of money to Trump’s successful presidential campaign and is widely thought to have close ties to Netanyahu. The Israeli leader, in other words, was apparently willing to literally sell out a political ally to ensure that he got friendlier coverage in the Israeli press.

Netanyahu was poised to make history. He may go to jail instead.

The potential indictment comes with Netanyahu close to accomplishing one of his biggest goals: outstripping David Ben-Gurion, the founder of the modern Israeli state, as the longest-serving leader in Israel’s history. (Netanyahu is serving his third consecutive term as prime minister; if he holds on until July 2019, he will have spent more time in office than Ben-Gurion.)

Netanyahu has spent 20 years at the forefront of Israeli politics — he served a term as prime minister in the late 1990s before beginning his current streak in 2009 — and remade much of the country in his own image. As Sheizaf writes, he’s changed Israel’s strategic priorities from seeking peace with the Palestinians to working to contain Iran, which he sees as an existential threat. Netanyahu has also helped decimate the country’s left-wing political parties and populated Israeli institutions with right-wing officials who hold religiously conservative and pro-settlement views.

That sparked years of vicious fighting with former President Barack Obama, who made no secret of his personal dislike for Netanyahu and repeatedly, and publicly, denounced Israel’s settlement policy. Obama approved a massive $38 billion military aid package with Israel, but the hostile feelings went both ways. There was probably no foreign leader happier about Trump’s surprise win than Netanyahu.

Now the Israeli leader faces a painful irony. Netanyahu has never had a closer friend and ally in the White House, but Trump — for all of his own legal and political challenges — may remain in office long after Netanyahu’s own career potentially comes to a crashing close.