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 US flags alongside each other.

​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 criticised, casting a pall over US-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 US 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 in 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 US 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 US embassy from Tel Aviv to Jerusalem.

The controversial orders Donald Trump has already issued Show all 9 1 /9 The controversial orders Donald Trump has already issued The controversial orders Donald Trump has already issued Trump and the media White House Press Secretary Sean Spicer takes questions during the daily press briefing Getty Images The controversial orders Donald Trump has already issued Trump and the Trans-Pacific Partnership Union leaders applaud US President Donald Trump for signing an executive order withdrawing the US from the Trans-Pacific Partnership negotiations during a meeting in the Roosevelt Room of the White House in Washington DC. Mr Trump issued a presidential memorandum in January announcing that the US would withdraw from the trade deal Getty The controversial orders Donald Trump has already issued Trump and the Mexico wall A US Border Patrol vehicle sits waiting for illegal immigrants at a fence opening near the US-Mexico border near McAllen, Texas. The number of incoming immigrants has surged ahead of the upcoming Presidential inauguration of Donald Trump, who has pledged to build a wall along the US-Mexico border. A signature campaign promise, Mr Trump outlined his intention to build a border wall on the US-Mexico border days after taking office Getty Images The controversial orders Donald Trump has already issued Trump and abortion US President Donald Trump signs an executive order as Chief of Staff Reince Priebus looks on in the Oval Office of the White House. Mr Trump reinstated a ban on American financial aide being granted to non-governmental organizations that provide abortion counseling, provide abortion referrals, or advocate for abortion access outside of the United States Getty Images The controversial orders Donald Trump has already issued Trump and the Dakota Access pipeline Opponents of the Keystone XL and Dakota Access pipelines hold a rally as they protest US President Donald Trump's executive orders advancing their construction, at Columbus Circle in New York. US President Donald Trump signed executive orders reviving the construction of two controversial oil pipelines, but said the projects would be subject to renegotiation Getty Images The controversial orders Donald Trump has already issued Trump and 'Obamacare' Nancy Pelosi who is the minority leader of the House of Representatives speaks beside House Democrats at an event to protect the Affordable Care Act in Los Angeles, California. US President Donald Trump's effort to make good on his campaign promise to repeal and replace the healthcare law failed when Republicans failed to get enough votes. Mr Trump has promised to revisit the matter Getty Images The controversial orders Donald Trump has already issued Donald Trump and 'sanctuary cities' US President Donald Trump signed an executive order in January threatening to pull funding for so-called "sanctuary cities" if they do not comply with federal immigration law AP The controversial orders Donald Trump has already issued Trump and the travel ban US President Donald Trump has attempted twice to restrict travel into the United States from several predominantly Muslim countries. The first attempt, in February, was met with swift opposition from protesters who flocked to airports around the country. That travel ban was later blocked by the Ninth Circuit Court of Appeals. The second ban was blocked by a federal judge a day before it was scheduled to be implemented in mid-March SANDY HUFFAKER/AFP/Getty Images The controversial orders Donald Trump has already issued Trump and climate change US President Donald Trump sought to dismantle several of his predecessor's actions on climate change in March. His order instructed the Environmental Protection Agency to reevaluate the Clean Power Plan, which would cap power plant emissions Shannon Stapleton/Reuters

“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 criticising 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 US Jews). It doesn't matter what we think of the wall, don’t we have enough troubles of our own?”

Although 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 US-Mexico relations.”