The projection published by GFS Bern polling and research group found that 62 percent had voted in favour of the reform, with a margin of error of three percent.
The new law will widen existing legislation against discrimination or incitement to hatred on ethnic or religious grounds to include sexual orientation.
“This is a historic day,” Mathias Reynard, a lawmaker from the Social Democratic Party of Switzerland who initiated the reform, told Swiss channel RTS 1.
“It gives a signal which is magnificent for everyone and for anyone who has been a victim of discrimination,” he said.
The change was passed by the Swiss parliament in 2018 but critics, who believe it will end up censoring free speech, had forced a referendum on the issue.
Eric Bertinat, an SVP local lawmaker in Geneva, told AFP before the vote that he believed the law was “part of an LGBT plan to slowly move towards same-sex marriage and medically assisted reproduction” for gay couples.
Marc Frueh, head of the Federal Democratic Union of Switzerland (EDU), a small party based on Christian values, said after the projection: “I accept defeat”.
“We will keep a close eye on how the law is implemented by the courts,” he told RTS 1.
All of Switzerland's major parties except the SVP, the biggest political force in parliament, support the law.
Rights campaigner Jean-Pierre Sigrist, founder of an association of gay teachers, had said before the referendum that the new law might have stopped him getting beaten up outside a bar in Geneva four decades ago.
“And maybe I would not have been laughed at when I went to the police,” the 71-year-old told AFP, adding that he hoped the reform would help to counter a resurgence of intolerance against gay people.
Sigrist said he supported freedom of expression, “but not the freedom to say anything at all”.
– 'No to Special Rights!' –
Under the new law, homophobic comments made in a family setting or among friends would not be criminalised.
But publicly denigrating or discriminating against someone for being gay or inciting hatred against that person in text, speech, images or gestures, would be banned.
The government has said it will still be possible to have opinionated debates on issues such as same-sex marriage, and the new law does not ban jokes — however off-colour.
“Incitement to hatred needs to reach a certain level of intensity in order to be considered criminal in Switzerland,” Alexandre Curchod, a media lawyer, told AFP.
But he admitted that there could be exceptions “if it can be shown that, under the cover of artistic production or joking, someone is in fact engaging in incitement”.
Gay rights campaigners were divided over the legislation.
A group called “No to Special Rights!” is opposed, arguing that the gay community does not need special protection.
Switzerland is holding a referendum on a law that would ban discrimination based on sexual orientation