JERUSALEM — Israel's Supreme Court on Thursday overturned an appeals court ruling that agreed with the government's decision to bar an American graduate student from entering the country over her alleged involvement in the boycott movement against the Jewish state.

The court accepted Alqasem's appeal, saying her desire to study in Israel undermines the premise of her alleged support for a boycott. It said that if her deportation was based on her political opinion, then the state's order was "a radical and dangerous step" that could erode Israeli democracy.

Lara Alqasem's lawyers said she was released from Ben Gurion International airport, where she had been held in detention since arriving in the country Oct. 2 with a valid student visa to study at the Hebrew University of Jerusalem.

Alqasem said in a statement that she was "relieved at the court's decision" and thankful for the support of her friends and family.

Alqasem, 22, a Florida native whose father is Palestinian, is a former president of the University of Florida chapter of Students for Justice in Palestine. The group is a branch of the BDS movement, named for its support of boycotts, divestment and sanctions against Israel.

Israel's Strategic Affairs Ministry, which spearheads the government's efforts against the boycott campaign, describes the group as an extremist organization and says BDS aims to delegitimize or even destroy the Jewish state.

Last year, Israel passed a controversial law banning entry for any foreigner who "knowingly issues a public call for boycotting Israel." It has come under heavy criticism for its handling of Alqasem's case.

Alqasem has fought her expulsion order for more than two weeks, the longest anyone has been held in a boycott-related case.

She turned to the high court Wednesday after a lower court rejected her appeal. She insists she no longer participates in boycott activities and promises not to engage in boycott activities in the future.

Her lawyers called the government's attack on Alqasem "thought-policing" and said the state failed to present credible evidence against her.

Government lawyers argued that Alqasem's deletion of her social media accounts aroused suspicion and that her past affiliation with the BDS movement still makes her a threat.

In its ruling, the Supreme Court said the state's evidence was not enough to justify its use of the anti-boycott law.

Alqasem's attorneys lauded the high court's ruling as a victory for free speech, academic freedom and the rule of law.

"Lara has ensured that no one else should be denied the right to enter Israel based on sloppy Google searches and dossiers by shadowy smear groups," lawyers Yotam Ben-Hillel and Leora Bechor said.

Gilad Erdan, head of Israel's Strategic Affairs Ministry, said the ruling was a victory for BDS and undermines Israel's anti-boycott law.

"I'm deeply disappointed," he said. "This damages the ability of the state of Israel to combat boycott activists that harm us all."

Interior Minister Aryeh Deri likewise lamented the court's decision, calling it a national embarrassment.

"Where is our national pride? Would she also have dared in the United States to act against the state while demanding to remain and study in it?" he wrote on Twitter.

Members of Israel's right-wing government have long criticized the court for being, in their eyes, too liberal in its interventions regarding policy toward Palestinians.

Hebrew University, which has vigorously backed Alqasem and joined in her appeals, said it looks forward to welcoming her to classes next week.