A nationwide margin of 55% in favour and 45% against was wider than expected, but the vote by cantons - the other majority needed for the referendum to pass - was much closer. After a Yes result from the last canton to be counted, Zurich, the result was 12-11.

Supporters hailed the vote as a decision to accept the responsibilities of international engagement and to end the myth of an Alpine nirvana aloof from the world and its problems. Neutrality would continue as before, they said.

The coalition of political parties, banks, churches and newspapers which lobbied for a Yes vote was backed overwhelmingly in French-speaking and urban areas.

Lined up against them were the older, conservative, German- and Italian-speaking Swiss who feared that joining the UN would cost money, compromise sovereignty and make neutrality the plaything of the security council's five permanent members, especially the United States.

The spectre of Swiss soldiers coming home in bodybags from UN-mandated military campaigns was raised. Opponents also accused the elite of frittering away a policy which kept the country out of two world wars merely to smooth hob-nobbing in New York.

Despite Geneva being the UN's European headquarters, Switzerland has resisted joining for five decades, forming a club of two with the Vatican state. It will become the organisation's 190th member.

Yesterday's vote is expected to revive momentum for a referendum on the far more ambitious commitment of joining the European Union.

A government statement said everyone would gain from the vote, adding: "Switzerland will now be better able to safeguard its interests and assume responsibilities in the world."

The UN secretary general, Kofi Annan, welcomed the decision.

Foreign governments had hoped for a Yes vote but refrained from lobbying openly lest it backfire with the famously independent Swiss. Denis McShane, Britain's foreign minister for the UN, said history had been made and isolationists routed.

"It is a fantastic result," he said. "It is great to start the 21st century with such strong support for the UN from one of the richest countries. It sends a signal to all of the world that this very proud, neutral and rather cautious nation thinks the UN is worth joining."

The world organisation would benefit from the full engagement of the Swiss, some of the canniest diplomats, said Mr McShane.

Of the 7.2m population, 1,484,818 people voted in favour and 1,236,067 against. A 1986 referendum on UN membership was hammered three to one, but the end of the cold war drained some of the appeal from isolation and a new, more outward-looking generation emerged.

What supporters hoped would be a low-key campaign turned into a battle for national identity when Christoph Blocher, a billionaire industrialist and leader of the rightwing Swiss People's party, plastered the country with posters showing an axe sundering the word "neutrality".

UN membership will weaken Switzerland, he said after the result was announced. "Freedom and the rights of the people will be limited, and neutrality will at the very least be deeply damaged."

His concentration on the small, German-speaking cantons almost paid off, said one diplomat, adding: "He went for gut arguments which appealed to the conservative, rainy-day types, of which this country is full. In the cities there was a sense of quiet despair that he would win."