Swiss voters have narrowly approved a plan to introduce voluntary electronic identity cards.
With all votes counted, 50.4% of those who voted said yes to the proposal, while 49.6% rejected it.
The closeness of the ballot is a surprise. Opinion polls had suggested up to 60% backed digital IDs, which also had the approval of the Swiss government, and both houses of parliament.
It was Switzerland's second vote on digital IDs. An earlier proposal was rejected in 2021, amid concerns the data would be held centrally, and controlled largely by private providers.
Sunday's revised proposal keeps the system in government hands. Data will be stored only on the smartphones of individual users, and digital IDs will be optional.
Citizens can continue to use national identity card if they choose, which has been standard for decades in Switzerland.
To further ease privacy concerns, a particular authority seeking information on a person – such as proof of age or nationality, for example – will only be able to check for those specific details.
It comes after the UK government announced plans earlier this week to introduce its own digital ID - which would be mandatory for employment - as part of efforts to curb the number of illegal migrants living and working in the country.
The proposed British digital ID would have fewer intended uses than the Swiss version, but has still raised concerns about privacy and data security.
Supporters of the Swiss system say it will make life much easier for everyone, allowing a range of bureaucratic procedures - from getting a telephone contract to proving you are old enough to buy a bottle of wine - to happen quickly online.
Opponents of digital ID cards, who gathered enough signatures to force another referendum on the issue, argue that the measure could still undermine individual privacy.
They also fear that, despite the new restrictions on how data is collected and stored, it could still be used to track people and for marketing purposes.
Switzerland has a long tradition of protecting its citizens' privacy. The banking secrecy laws, now much diluted, were designed to shield an individual's personal finances from the prying eyes of the state.
For years, Google Street View was controversial in Switzerland - and even today, following a ruling by the Swiss Federal Court, images taken close to schools, women's refuges, hospitals or prisons must be automatically blurred before going online.