Nearly two-thirds of Swiss voters backed the introduction of same-sex marriage in a referendum held Sunday, with campaigners calling it a historic moment for gay rights in Switzerland.
The government's plans to introduce "marriage for all" were challenged by opponents, who successfully triggered a referendum.
But some 64.1 percent of voters in the wealthy Alpine nation supported the move, on a 52 percent turnout.
"It is a historic day for Switzerland, a historic day when it comes to equality for same-sex couples, and it is also an important day for the whole LGBT community," said Jan Muller of the "yes" campaign committee.
Switzerland is the world's 30th country to adopt same-sex marriages, and was one of the last remaining western European nations yet to do so. The Netherlands was the first in 2001.
Justice minister Karin Keller-Sutter said the first same-sex marriages should be able to take place from July 1 next year.
"Whoever loves each other and wants to get married will be able to do so, regardless of whether it is two men, two women, or a man and a woman," she said.
"The state does not have to tell citizens how they should lead their lives."
A majority in all 26 cantons voted yes -- even the most conservative. Support was strongest in Basel City at 74 percent.
"The Swiss have dropped a massive 'yes' into the ballot box," Olga Baranova, a spokeswoman for the "yes" committee, told AFP.
She was at a restaurant in the Swiss capital Bern hosting the "yes" campaign's celebrations -- decked out in balloons in the rainbow colours -- where drag artist Mona Gamie sang Edith Piaf's "Hymn to Love" to rapturous applause.
"Today does not change my country," Baranova said.
"Today reflects the change of mentality over the last 20 years. It is really the reflection of a very broad and very important acceptance of LGBT people in society."
Switzerland decriminalised homosexuality in 1942. Same-sex couples can register a civil partnership, with around 700 established each year.
However, this status does not provide the same rights as marriage, including for obtaining citizenship and the joint adoption of children.
After years of debate, the Swiss parliament approved a bill last December allowing same-sex couples to marry, in the country of 8.6 million people.
But it was challenged under Switzerland's direct democracy system, with opponents gathering the 50,000 signatures needed to put the issue to a referendum.
Deborah Heanni, a member of the Libero collective which pushed for a "yes", told AFP: "After eight years of campaigning, we are happy finally to be able to celebrate this victory."
The law change will allow same-sex couples to marry in civil ceremonies and provide them with the same rights as other married couples.
Foreign spouses will become eligible to apply for citizenship through a simplified procedure, and same-sex couples will be permitted to jointly adopt.
And, in what proved the most controversial aspect of the referendum campaign, lesbian couples will have access to sperm donations.
The right-wing populist Swiss People's Party (SVP) -- Switzerland's largest political party -- called for a "no" vote.
Opponents plastered cities with stark posters decrying the commodification of children and warning the law will "kill the father".
One poster showed a crying baby with its ear tagged like cattle, and the question: "Babies on demand?"
Another featured a huge zombie-like head meant to represent a dead father.
"Everyone will be disappointed," Yohan Ziehli, vice president of the SVP branch in the French-speaking Vaud canton.
"Parliament made the tactical choice to link two subjects that should not have been, namely the question of parentage which has been hidden behind the shield of marriage for all in order to guarantee its success," he told broadcaster RTS.
A second vote was held on an initiative entitled titled "Reduce taxes on wages, tax capital equitably".
Proponents wanted greater taxation on high levels of capital income, with the revenues generated used to reduce income taxes for the less well off.
However, 65 percent voted against the measure.