JERUSALEM (Reuters) - When Benjamin Netanyahu sent a tweet in support of President Donald Trump's plan for a wall along the Mexican border, the Israeli prime minister can barely have expected it would be retweeted 40,000 times and cause a backlash at home and abroad.

Already under arguably the greatest pressure he has faced in his 11 years as prime minister, with police questioning him in two criminal probes into abuse of office, aligning himself with Trump may further undermine his standing.

The tweet, sent from his personal account shortly before the Jewish sabbath officially ended on Saturday, was very clear:

"President Trump is right. I built a wall along Israel's southern border. It stopped all illegal immigration. Great Success. Great idea," Netanyahu wrote, appending pictures of the Israeli and U.S. flags alongside each other.

PHOTOS: Netanyahu in recent years

17 PHOTOS Israeli Prime Minister Benjamin Netanyahu See Gallery Israeli Prime Minister Benjamin Netanyahu President Donald Trump welcomes visiting Israeli Prime Minister Benjamin Netanyahu to the White House in Washington, Monday, March 25, 2019. (AP Photo/Manuel Balce Ceneta) President Donald Trump and Vice President Mike Pence, greet Israeli Prime Minister Benjamin Netanyahu to the South Lawn of the White House in Washington, Monday, March 25, 2019. (AP Photo/Susan Walsh) Visiting Israeli Prime Minister Benjamin Netanyahu and President Donald Trump hold up the signed proclamation recognizing Israel's sovereignty over the Golan Heights as Netanyahu leaves the White House in Washington, Monday, March 25, 2019. (AP Photo/Manuel Balce Ceneta) President Donald Trump and visiting Israeli Prime Minister Benjamin Netanyahu walk along the Colonnade of the White House in Washington, Monday, March 25, 2019. (AP Photo/Manuel Balce Ceneta) U.S. Secretary of State Mike Pompeo shake hands with Israeli Prime Minister Benjamin Netanyahu, during their visit at Netanyahu's official residence in Jerusalem, Thursday March 21, 2019. (Jim Young/Pool Image via AP) Israeli Prime Minister Benjamin Netanyahu chairs the weekly cabinet meeting at his Jerusalem office Sunday, March 17, 2019. (AP Photo/Ariel Schalit, Pool) Israeli Prime Minister Benjamin Netanyahu attends the weekly cabinet meeting in Jerusalem on January 22, 2017. / AFP / POOL / RONEN ZVULUN (Photo credit should read RONEN ZVULUN/AFP/Getty Images) NEW YORK, NEW YORK - SEPTEMBER 21: (L to R) Prime Minister of Israel Benjamin Netanyahu speaks to U.S. President Barack Obama during a bilateral meeting at the Lotte New York Palace Hotel, September 21, 2016 in New York City. Last week, Israel and the United States agreed to a $38 billion, 10-year aid package for Israel. Obama is expected to discuss the need for a 'two-state solution' for the Israeli-Palestinian conflict. (Pool Photo by Drew Angerer/Getty Images) NEW YORK, NEW YORK - SEPTEMBER 22: Prime Minister of Israel Benjamin Netanyahu addresses the United Nations General Assembly at UN headquarters, September 22, 2016 in New York City. According to the UN Secretary-General Ban ki-Moon, the most pressing matter to be discussed at the General Assembly is the world's refugee crisis. (Photo by Drew Angerer/Getty Images) JERUSALEM, ISRAEL - NOVEMBER 18: Israeli Prime Minister Benjamin Netanyahu speaks during a press conference on November 18, 2014 in Jerusalem, Israel. Netanyahu said incitement by the Palestinian Authority, Hamas and Islamic Jihad led to a terrorist attack in a Jerusalem synagogue, which killed four worshippers and wounded several others. (Photo by Lior Mizrahi/Getty Images) JERUSALEM, ISRAEL - JUNE 02: Israeli Prime Minister Benjamin Netanyahu (R) speaks with Military Secretary Eyal Zamir during the weekly cabinet meeting in his office on June 2, 2013 in Jerusalem, Israel. (Photo by Sebastian Scheiner - Pool/Getty Images) Israeli Prime Minister Benjamin Netanyahu speaks to the press in the southern Israeli port of Eilat, on March 10, 2014, as Israel displayed advanced rockets type M-302 capable of reaching distances of up to 200 km that were unloaded from the Panamanian-flagged Klos-C vessel on March 9, 2014 in the southern Israeli port of Eilat. The vessel, which was allegedly transporting arms from Iran to Gaza, was escorted into the port of Eilat after Israeli naval commandos seized it on March 5, 2014. AFP PHOTO / JACK GUEZ (Photo credit should read JACK GUEZ/AFP/Getty Images) JERUSALEM, ISRAEL - JANUARY 22: Israeli Prime Minister Benjamin Netanyahu touches the Western Wall, Judaism holiest site, on January 22, 2013 in Jerusalem, Israel. The latest opinion polls suggest that current Prime Minister Benjamin Netanyahu will return to office, albeit with a reduced majority. (Photo by Uriel Sinai/Getty Images) JERUSALEM, ISRAEL - JANUARY 22: (ISRAEL OUT) Israeli Prime Minister Benjamin Netanyahu casts his ballot at a polling station on election day on January 22, 2013 in Jerusalem, Israel. Israel's general election voting has begun today as polls show Netanyahu is expected to return to office with a narrow majority. (Photo by Uriel Sinai/Getty Images) SDE BOKER, ISRAEL - NOVEMBER 20: Israeli Prime Minister Benjamin Netanyahu and Israeli President Shimon Peres attend the annual memorial ceremony for David Ben-Gurion, Israel's first Prime Minister, in Sde Boker on November 20, 2012 in southern Israel. Hamas militants and Israel are continuing talks aimed at a ceasefire as the death toll in Gaza reaches over 100 with three Israelis also having been killed by rockets fired by Palestinian militants. (Photo by Dan Balilty - Pool /Getty Images) NEW YORK, NY - SEPTEMBER 23: Benjamin Netanyahu, Prime Minister of Israel, delivers an address to the 66th General Assembly Session at the United Nations on September 23, 2011 in New York City. The annual event, which is being dominated this year by the Palestinian's bid for full membership, gathers more than 100 heads of state and government for high level meetings on nuclear safety, regional conflicts, health and nutrition and environment issues. (Photo by Mario Tama/Getty Images) JERUSALEM, ISRAEL - APRIL 10: Israeli Prime Minister Benjamin Netanyahu chairs the weekly cabinet meeting at his offices on April 10, 2011 in Jerusalem, Israel. Both Israel and Hamas have expressed a willingness to call a truce to cross-border violence that in the past few days has claimed at least 19 Palestinian lives in retaliatory Israeli air strikes. (Photo by Jim Hollander - Pool/Getty Images) Up Next See Gallery Discover More Like This HIDE CAPTION SHOW CAPTION of SEE ALL BACK TO SLIDE

Netanyahu was referring to a steel fence Israel has built along its border with Egypt, mainly to keep out migrants fleeing conflicts in Africa, including Somalis, Sudanese and Eritreans.

Israel has also built a steel-and-concrete barrier along its border with the occupied West Bank, which it says is to prevent militants crossing into Israel. Palestinians see the barrier, which has drawn international condemnation, as a land grab.

On the one hand, Trump's election as president was seen as a godsend for Netanyahu, the first time in four terms as prime minister that he would have a Republican in the White House.

As well as the Republicans being more ideologically aligned with Netanyahu's right-wing coalition, Trump has already shown a willingness to turn a blind eye to Israel's settlement building in the West Bank, which Barack Obama's administration frequently criticized, casting a pall over U.S.-Israeli ties.

On the other hand, Trump is an unpredictable actor who in just nine days in office has sewn division across the United States and shocked capitals around the world with a series of executive actions that are overturning decades of U.S. policy.

The adverse reaction to Netanyahu's tweet, which was retweeted by Trump and drew far more attention than Netanyahu's tweets usually do as a result, appeared to be an early sign of the danger Netanyahu faces with aligning himself with Trump.

The Mexican government was outraged that he would involve himself in what it regards as a bilateral issue.

"The foreign ministry expressed to the government of Israel, via its ambassador in Mexico, its profound astonishment, rejection and disappointment over Prime Minister Netanyahu's message," the foreign ministry said in a statement.

"Mexico is a friend of Israel and should be treated as such by its Prime Minister."

Dan Shapiro, who served as ambassador to Israel under Obama until nine days ago and still lives in the country, ditched diplomacy to question Netanyahu's motives in sending the tweet.

"Hard to explain this intervention on a hotly debated issue in domestic U.S. politics. Unless this endorsement is Trump's demand of Netanyahu for something Netanyahu wants," he wrote on Twitter, suggesting it may be linked to Trump's promise to move the U.S. embassy from Tel Aviv to Jerusalem.

"To me, it looks like Trump is already squeezing Netanyahu hard."

Opposition politician Yair Lapid, who is ahead of Netanyahu in recent opinion polls, was also scathing. Whereas Lapid has shied away from criticizing Netanyahu over the police investigations into him, this time he didn't hold back:

"A serious mistake by Netanyahu," Lapid tweeted in Hebrew.

"It is a needless declaration of war on Mexico and Hispanics and a rupture with the Democrats (including the majority of U.S. Jews). It doesn't matter what we think of the wall, don't we have enough troubles of our own?"

Though Netanyahu has not deleted the tweet, Israel's foreign ministry immediately sought to nuance its content.

The prime minister was referring to Israel's "specific security experience", the foreign ministry spokesman said, adding: "We do not express a position on U.S.-Mexico relations."

(Additional reporting by Jeffrey Heller; Editing by Raissa Kasolowsky)