MEXICO CITY (Reuters) - Mexico’s government rebuked Israel on Saturday for a tweet by Prime Minister Benjamin Netanyahu that appeared to applaud U.S. President Donald Trump’s plan to build a border wall with Mexico to keep out illegal immigrants.

Israeli Prime Minister Benjamin Netanyahu speaks during an event marking International Holocaust Remembrance Day, marked on January 27, at the Yad Vashem synagogue in Jerusalem January 26, 2017. REUTERS/Amir Cohen

Netanyahu said on Twitter earlier on Saturday: “President Trump is right. I built a wall along Israel’s southern border. It stopped all illegal immigration. Great success. Great idea.”

The comment was swiftly rejected by leaders of the Jewish community in Mexico, and prompted an unusually blunt statement from Mexico’s foreign ministry.

“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 on Twitter about the construction of a border wall,” the ministry’s statement.

“Mexico is a friend of Israel and should be treated as such by its Prime Minister,” it said, noting that Foreign Minister Luis Videgaray expressed his deep affection for Israel in an event marking Holocaust memorial day on Friday.

Israeli Foreign Ministry spokesman Emmanuel Nahshon said on Twitter Netanyahu had been referring to his country’s “specific security experience” and that Israel was not voicing an opinion on U.S.-Mexican relations.

Mexico’s government and Trump have been locked in a bitter dispute over his election campaign promise to build a wall on the U.S. southern border that he says Mexico will pay for. Mexico has repeatedly said it will not pay for the wall.

The Central Committee of the Jewish Community in Mexico issued a statement saying it “forcefully rejected” Netanyahu’s comment, while several prominent Mexicans of Jewish origin sharply criticized the Israeli leader on Twitter.

“So you like walls @netanyahu? Here you have a couple of nice designs,” said Mony de Swaan, a former head of the Mexican telecommunications regulator, posting images of walls commemorating Bergen-Belsen, the Nazi concentration camp where diarist Anne Frank died, and the Warsaw Ghetto.

On Thursday, Mexican President Enrique Pena Nieto cancelled a visit to meet Trump next week after the American advised him to forgo the trip if he was not willing to pay for the wall.

The leaders pledged to work out their differences in a call on Friday morning, and the Mexican government said the two had agreed not to discuss the issue of payment for now.