The approval of the law late Monday was defended by government ministers and supporters as a necessary response to the movement that calls for Israel to be boycotted over its 50-year occupation of the Palestinian territories.
Israel sees the boycott movement as a strategic threat and accuses it of anti-Semitism -- a claim activists deny, saying they only want to see the occupation end.
The law follows other recent measures seen as targeting left-wing NGOs, and human rights groups said it could affect their work.
Israel has been faced with boycott calls for decades, but the movement known as BDS (Boycott, Divestment and Sanctions) has raised its profile in recent years with help from famous backers such as Roger Waters.
In response, Israeli politicians have become more combative under Prime Minister Benjamin Netanyahu's current coalition government, seen as the most right-wing in the country's history.
Last year, Israel budgeted 118 million shekels ($32 million, 30 million euros) to fight the movement.
The bill, which passed by a vote of 46 to 28, means visas and residence permits will not be given to those who have "knowingly issued a public call to boycott the state of Israel or pledged to take part in such a boycott," a parliament statement said.
It applies to those who are not Israeli citizens or permanent residents, and includes those who are members of organisations calling for a boycott, it said.
"We think that border control should not be used as thought control," Hagai El-Ad, executive director of prominent Israeli human rights group B'Tselem, told journalists.
He moted that Israel also controls who enters the Palestinian territories, apart from through one border crossing into Gaza from Egypt, and said the law could "absolutely" affect his group's work.
Signup to our newsletter and follow us on Facebook and Twitter!
The law defines boycott as "deliberately avoiding economic, cultural or academic ties with another person or body solely because of their affinity with the state of Israel, one of its institutions or an area under its control, in such a way that may cause economic, cultural or academic damage."
The reference to "an area under its control" means the law also applies to activists' calls to shun dealings with Jewish settlements in the occupied territories.
Public Security Minister Gilad Erdan defended the law on Tuesday, saying "every country has the right to determine who enters its borders."
He called it "another step in our struggle against those who seek to delegitimize Israel while hiding behind the language of human rights, and they do it from time to time."
But Jewish Voice for Peace, a US human rights group supporting BDS, went as far as to compare the law to US President Donald Trump's revised ban on refugees and travellers from six Muslim-majority nations.
"Israel just passed its own discriminatory travel ban barring supporters of nonviolent tactics to end Israelùs violations of Palestinian rights," its executive director Rebecca Vilkomerson said in a statement.
"My grandparents are buried in Israel, my husband and kids are citizens, and I lived there for three years, but this bill would bar me from visiting because of my work in support of Palestinian rights."
Anti-settlement NGO Peace Now called the law "neither Jewish nor democratic."
It said it "will not prevent the boycott but just erode Israel's standing in the world and lead us toward international isolation."
Those who supported the bill however said it was simply a matter of self-defence, saying Israel should not open its doors to those they allege want to harm the country.
"If someone demeans me, I do not let them into my home," said David Amsalem, a lawmaker from Netanyahu's Likud party, according to the Jerusalem Post.
MP Manuel Trajtenberg, of the main opposition Zionist Union alliance, said he believed constructive engagement with the boycott lobby was a better option.
"For 10 years I've repeatedly confronted BDS and I have brought some of them here to show them that they are mistaken," he said during Monday night's debate.