Israel’s highest court has upheld the government’s decision to deport the local director of Human Rights Watch (HRW) for his alleged support for a boycott movement, ending a long-running landmark case that questioned the country’s ability to expel its critics.

Omar Shakir, a US citizen, will now have 20 days to leave Israel and the Palestinian territories or face deportation, his lawyer said.

Shakir wrote on Twitter that if he was kicked out, Israel would join the ranks of Iran, North Korea and Egypt in blocking access to Human Rights Watch staff. “We won’t stop. And we won’t be the last,” he said.

HRW has called the government’s attempts to deport Shakir, which have been going on for more than a year, a sign that Israel was seeking to suppress criticism.

“The supreme court has effectively declared that free expression in Israel does not include completely mainstream advocacy for Palestinian rights,” said Kenneth Roth, the group’s executive director.

Shakir will be removed under a contentious 2017 law that allows the government to block entry to people who support a boycott of Israel or Jewish settlements in the occupied West Bank.

The measure was designed to criminalise the boycott, divestment and sanctions (BDS) movement. Rights groups say it tramples on free speech as the law has been deployed against critics and activists.

In its most high-profile use, Israel blocked in August two US congresswomen, Ilhan Omar and Rashida Tlaib, from a planned trip to Palestine and Jerusalem.

The Democratic party lawmakers had previously said they supported the use of boycotts to pressure governments, including that of Israel, on human rights abuses. They also sought to pass a resolution in the House of Representatives championing the right to participate in boycotts.

Israel later agreed to a request by Tlaib to visit on humanitarian grounds on the condition that she did not express her views on the boycott. Tlaib rejected the offer.

HRW says the Shakir case is significant as it is the first time the government has used the anti-BDS legislation to try to deport someone legally working in the country.

Shakir has argued he had not called for any form of boycott of Israel during his time at HRW.

His employer has suggested he was targeted for the organisation’s opposition to Israel’s Jewish settlements in the West Bank and its calls for companies to stop working with them.

HRW has pointed out it had written critical reports on human rights violations on both sides including the arbitrary detention of journalists and activists by the Palestinian Authority and Hamas and an extrajudicial execution carried out by Hamas’s military wing.

Last week, another rights group, Amnesty International, accused Israel of blocking one of its staff members from travelling abroad for undisclosed security reasons as a “punitive measure against the organisation’s human rights work”.

Laith Abu Zeyad, Amnesty International’s campaigner on Israel and the occupied Palestinian Territories, was stopped at a border crossing with Jordan while on his way to attend a relative’s funeral.