Prime Minister Benjamin Netanyahu pulled out all the stops to convince voters that he is the man who can keep Israel great ahead of Tuesday's election.

Netanyahu has led right-wing governments in Israel for a decade, but a vital part of his tough re-election campaign sits 10,000 miles away in Washington: Donald Trump.

However, Netanyahu and his Likud party are being severely tested by Benny Gantz, a general former chief of staff of Israel's military.

Gantz, 59, has sought to contrast his path with his that of his rival.

“When I trained generations of commanders and fighters, you were taking acting lessons in a New York studio,” said Gantz, a political novice who heads the centrist Blue and White party.

Benny Gantz, who is one of the leaders of the Blue and White party, casts his vote alongside wife Revital Gantz on Tuesday. Sebastian Scheiner / AP

He has also highlighted the scandals surrounding Netanyahu and accused his government of indulging "in the pleasures of power, corruption and hedonism.

"I am looking the people of Israel in the eyes and telling them, 'This change is possible,'" Gantz said as he cast his vote Tuesday. "Together we will take this new path. I call out to all of you — let's respect democracy and go vote.”

Most polls show fledgling Blue and White, which was only established in February, is ahead of Likud.

But with 40 parties competing, a government will need to be built from a variety of them. Polls suggest that a Netanyahu-led coalition is most likely to emerge but negotiations as part of that process are likely to take days or weeks.

If Netanyahu remains prime minister, he will embark on his fourth consecutive and fifth overall term and become Israel’s longest-serving leader, surpassing the country’s founding father David Ben-Gurion.

Here is a primer on the looming showdown as Israelis prepare to go to the ballot box.

The Trump effect

Trump has been a steadfast of ally for Netanyahu, dubbed "King Bibi" by fans and detractors, even when compared to decades of close relations between the countries. Campaign billboards showing the two together underscore the point.

A billboard in Jerusalem showing Donald Trump shaking hands with Benjamin Netanyahu. Ammar Awad / Reuters

Trump has made a series of decisions that have endeared him to the prime minister, and many Israeli voters. The U.S.'s withdrawal from the nuclear agreement Iran — which many Israelis see as an existential threat — was a coup for Netanyahu. Then came the decision to move the U.S. embassy to Jerusalem. And on March 21, Trump recognized Israel's annexation of the Golan Heights, which Israel captured from Syria in 1967.

Trump's envoy to Israel, David Friedman, is popular among Israeli right-wing voters. He has written articles against a two-state solution and given money to groups supporting Jewish settlements in the West Bank.

Trump "seems to be aligned with Netanyahu on a whole host of issues, including some truly dramatic iconoclastic kinds of decisions," according to Natan Sachs, director of the Center for Middle East Policy at the Brookings Institution, a Washington think tank.

As if to drive home the relationship, Netanyahu visited the White House on March 25. And on Monday, he issued a personal message to Trump after the administration announced it was designating the Iranian Revolutionary Guard Corps, or IRGC, as a foreign terrorist organization.

"Thank you, my dear friend," he said. "Thank you for responding to another important request of mine, which serves the interests of our countries and countries of the region."

Israel's Prime Minister Benjamin Netanyahu votes in Jerusalem on Tuesday. Ariel Schalit / AP

Still, Trump this weekend kept his options open, saying that Netanyahu and Gantz were "both good people."

On Feb. 28, Israel's attorney general recommended indicting Netanyahu on bribery, fraud and breach of trust in three different cases. Netanyahu has also been caught up in a scandal involving the $2 billion purchase of submarines from Germany's ThyssenKrupp. Although not a suspect, police have recommended that his personal attorney who is also his cousin be indicted on charges of bribery and money laundering.

Taking a page out of Trump's playbook, Netanyahu has called the investigations a “witch hunt.”

When in doubt, go right

Netanyahu on Saturday promised to annex Jewish settlements in the West Bank, which most world governments — including Democratic and Republican U.S. administrations — have deemed illegally occupied by Israel. This looked aimed at rallying the nationalist vote ahead of election day and followed a series of hard-line moves.

A Blue and White party campaign poster depicting leaders including Benny Gantz, left, sits next to a billboard showing Prime Minister Benjamin Netanyahu with members of far-right Jewish Power political party. Ammar Awad / Reuters

Netanyahu's coalition has included religious, far-right and marginal parties in the past. But a recent decision to forge an alliance with a fringe extremist party inspired by an American-born rabbi, Meir Kahane, who advocated a Jewish theocracy and the forced removal of Palestinians, raised the alarm even among some Netanyahu allies.

July's passage of the “nation-state” law declaring only Jews had the right of self-determination and stripping Arabic of its designation as an official language alongside Hebrew was also decried by critics who say it institutionalized discrimination.

The prime minister, meanwhile, has targeted the “elite” and waged war on government institutions. More recently Netanyahu has criticized Gantz for being a "leftist" and his campaign has warned that the former military chief would form a coalition with Arab parties.

“Netanyahu's argument is taken from Trump's deep-state argument,” according to Gayil Talshir, a political scientist professor at Hebrew University in Jerusalem. The message Netanyahu is sending his supporters is that the “left cannot defeat me through elections, so they try to oust me undemocratically through the police, courts and media,” she said.

Getting along with the neighbors

National security is always a key issue in Israel.

Netanyahu's record of facing off threats on Israel’s borders, including from Hezbollah militants in Lebanon and keeping Israel on the sidelines of the Syrian civil war, remain among his most popular achievements. He has also earned plaudits for taking the country into only one major conflict — with Hamas militants in the Gaza Strip in 2014.

But Israel has fought a series of wars with its Arab neighbors since its founding in 1948, leaving it isolated, so Netanyahu has been eager to highlight his outreach to leaders of Arab Gulf kingdoms. None of the countries have formal relations with Israel, but a shared antipathy toward Iran and eagerness to develop commercial ties have seen most soften their positions, while also quietly distancing themselves from the Palestinian cause.

Oman's Sultan Qaboos bin Said welcomed Netanyahu for a visit in late October.

On March 27, a senior United Arab Emirates official told The National newspaper that the “Arab decision not to have contact with Israel” was a “very, very wrong decision.”

Netanyahu, 69, has pursued leaders further afield. A case in point was Thursday's meeting with Russia’s Vladimir Putin following Moscow's help in the return of remains of a U.S.-born Israeli soldier missing in Lebanon since 1982.

But even with his military chops, Gantz has struggled to compete with this image of an international statesman.

Benny Gantz after being named Israel's military chief in 2011. Jack Guez / AFP/Getty Images file

While Netanyahu is largely seen as hawkish, earning the nickname "Mr. Security," he has also been criticized by former allies for not doing enough to stop attacks from Gaza.

"There are charges that he does not protect the people on the south of Israel," said Talshir.

Netanyahu also "did not use the relatively peaceful time in the south for negotiating a better deal with PLO and Hamas on security," she added, referring to the main Palestinian groupings.

The Palestinian question

Whether it is the around 20 percent of non-Jewish Israelis who have a right to vote, or those in the occupied West Bank and blockaded Gaza Strip, Palestinians have been absent from most campaigning.

In the run up to the election, Netanyahu has not offered a plan for what many believe is the country's most important challenge — what to do about millions of Palestinians under Israeli military occupation.

Gantz, meanwhile, has said spoken of "separation" and released a campaign video touting his achievement in bombing Gaza back to the “Stone Age.”

“For Palestinians — whether citizens of Israel or living under undemocratic Israeli military rule in the West Bank and Gaza Strip — these elections are the equivalent of a choice between Trump and Trump,” said Diana Buttu, a former adviser to Palestinian President Mahmoud Abbas and an Israeli citizen.

“This election will likely result in an even more extreme, right-wing extreme government than the last — which was the most right-wing in Israel's history: an outcome that does not bode well for Palestinians, the region, or the world,” she added.

F. Brinley Bruton reported from London, Paul Goldman from Tel Aviv and Lawahez Jabari from Jerusalem.