Official results showed the measure passed with 64.1% with the result earning a majority in each of Switzerland's 26 states.
The result will bring the country's rules around marriage in line with many of its neighbours.
Justice Minister Karin Keller-Sutter tweeted that the government will implement the decision quickly and, under current plans, the new rules can take effect on July 1 next year.
Switzerland’s parliament and the governing Federal Council — on which it sits — had supported the “Marriage for All” measure, which marks a key step for greater rights for gays and lesbians in Switzerland.
The country has authorised same-sex civil partnerships since 2007.
“With this, all couples will in the future be treated equally before the law: all can enter into a civil marriage, with the same rights and obligations,” Keller-Sutter wrote.
The new law is set to put same-sex partners on an equal legal footing with heterosexual couples by allowing them to adopt children and facilitating citizenship for same-sex spouses.
It will also permit lesbian couples to utilise regulated sperm donation.
Switzerland is well known for its form of direct democracy which sees it holding regular referendums on various legislative issues.
“This is a historic day for us and for Switzerland, this is a great step forward, something we have been waiting for for years,” said Laura Russo, co-president of the Geneva Federation of LGBT Associations, at a gathering of joyous supporters of the measure along a Geneva pedestrian street.
“This initiative was begun in 2013; we had to wait eight years for the vote to happen — and here, this is a big ‘Yes.’”
Opponents believed that replacing civil partnerships with full marriage rights would undermine families based on a union between a man and a woman.
Benjamin Roduit of the Christian Democratic People’s Party, which spearheaded the effort to stop same-sex marriage, claimed at least some success in raising awareness about his party’s positions despite the huge defeat at the ballot box.
“On our side we have tried to draw attention to the central problem, the one of children and medically assisted procreation,” he said.
“On that point, I think we have succeeded in raising awareness among the Swiss people and we will still be here when other steps will be proposed.”
The campaign has been rife with allegations of unfair tactics, with the opposing sides decrying the ripping down of posters, LGBT hotlines getting flooded with complaints, hostile emails, shouted insults against campaigners and efforts to silence opposing views.
Switzerland, which has a population of 8.5 million, is traditionally conservative and only extended the right to vote to all women in the country in 1990.
Most countries in Western Europe already recognise same-sex marriage, while most of those in Central and Eastern Europe don’t permit wedlock between two men or two women.
At a polling station in Geneva, voter Anna Leimgruber said she cast her ballot for the “no” camp because she believed “children would need to have a dad and a mum.”
But Nicolas Dzierlatka, who voted “yes,” said what children need is love.
“I think what’s important for children is that they are loved and respected — and I think there are children who are not respected or loved in so-called ‘hetero’ couples,” he said.