Bolivians have narrowly rejected changing the constitution so President Evo Morales can run for a fourth term.
About 51.5% voted against the move with almost all the votes counted, the electoral authority said.
Mr Morales, Bolivia's first head of state of indigenous origin, has said he will respect the referendum result.
The constitutional change would have allowed Mr Morales to run for re-election in 2019 and potentially remain in power until 2025.
Observers said the count has been slow but that there was no evidence of fraud.
Pollsters had suggested a victory for the "No" camp based on unofficial quick counts, prompting celebrations by "No" campaigners in various Bolivian cities.
Mr Morales is still a popular leader and the economy has grown steadily over the past decade.
But many, especially in the main cities, think Mr Morales should not be allowed to serve 19 consecutive years as president, analysts say.
Opposition leader Samuel Doria Medina urged Mr Morales to "recognise the results" and focus on solving Bolivia's problems in his remaining time in office instead of trying to run for another term.
An indigenous Aymara and former coca leaf producer, he took office in January 2006, and his current term ends in 2020.
"With my record, I can leave happily and go home content. I would love to be a sports trainer," Mr Morales was earlier quoted as saying in an interview (in Spanish) with the Spanish newspaper El Pais.
However, he also accused right-wingers of waging a "dirty war" against him.
Observers say there is no clear successor to him and that the opposition lacks a single leader.
Despite a drop in the international price of oil and natural gas, the Bolivian economy has performed well in the past 10 years, growing on average 5% a year.
The government's socialist policies have also been successful in reducing extreme poverty.
But recent allegations that Mr Morales used his influence to favour a Chinese construction firm in Bolivia have damaged his approval ratings.
A former girlfriend of Mr Morales, Gabriela Zapata, holds an important position in the company, CAMC, which has secured more than $500m (£350m) in contracts with the Bolivian government.
Mr Morales rejected the allegations and said he had nothing to hide. He ordered an investigation into how the contracts were awarded.