By Luke Baker

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 🇮🇱🇺🇸 — Benjamin Netanyahu (@netanyahu) January 28, 2017

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 sown 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 dangerNetanyahu 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)