A US judge has temporarily blocked the implementation of a law that bars anyone from entering into a contract with the state of Kansas without first pledging they will not boycott Israel.

US District Court judge Daniel Crabtree granted the temporary injunction on Tuesday in response to a lawsuit filed by Kansas public school teacher Esther Koontz late last year.

Passed in June 2017, the Kansas legislation requires all state contractors to declare in writing that they do not support a boycott of Israel.

Koontz argues the law violates her rights under the First Amendment.

In his ruling, Crabtree wrote: "The Supreme Court has held that the First Amendment protects the right to participate in a boycott like the one punished by the Kansas law."

The American Civil Liberties Union (ACLU), which represented Koontz in court, welcomed the decision.

"The court has rightly recognised the serious First Amendment harms being inflicted by this misguided law, which imposes an unconstitutional ideological litmus test," said ACLU lawyer Brian Hauss in a statement.

Koontz, a public school math teacher, was asked to sign a document saying she was not boycotting Israel in July 2017 before she could work as a trainer in a state-run math and science programme, the court filing states.

However, she had begun boycotting Israeli companies and Israeli companies operating in the occupied Palestinian territories last year in protest of Israel's treatment of Palestinians.

After refusing to sign the form, she was not given the contract, the case states.

"This ruling should serve as a warning to government officials around the country that the First Amendment prohibits the government from suppressing participation in political boycotts," Hauss said.

Yousef Munayyer, executive director of the US Campaign for Palestinian Rights, welcomed the court's decision, saying on Twitter that "the 1st Amendment triumphed today".

There are laws like this that have passed in states across the country and @SenatorCardin is still pushing one in the senate. Thankfully, the 1st Amendment triumphed today! https://t.co/4L4XHJFIeS — (((YousefMunayyer))) (@YousefMunayyer) January 30, 2018

The Kansas legislation comes amid a growing crackdown in the US on the Palestinian-led boycott, divestment and sanctions (BDS) movement

Launched in 2005, BDS seeks to pressure Israel to end its occupation of the Palestinian territories and respect the rights of Palestinian refugees and Palestinian citizens of the state.

Last October, Wisconsin also passed a law barring state agencies from entering into contracts with entities that are "engaging in a boycott of Israel". Also in October, the governor of Maryland signed an executive order blocking firms that boycott Israel from receiving state contracts that same month.

As of this month, 24 states have enacted anti-BDS laws, according to Palestine Legal, a US-based legal advocacy group. Eleven other states have anti-BDS legislation pending.

A US Senate bill, known as the Israel Anti-Boycott Act, has also been proposed and would bar US citizens from supporting "restrictive trade practices or boycotts fostered or imposed by any international governmental organisation against Israel".