Bolivians were asked to vote on a change to the country's constitution. Presently, the president and vice-president are limited to two consecutive five-year terms.
Mr Morales, who has been in power since 2006, and his supporters wanted him to be able to run for another term.
With almost all the votes counted, the "No" camp had a narrow but irreversible lead over those favouring another term for Mr Morales.
This means the constitutional ban on serving more than two consecutive five-year terms remains in place.
Despite the constitutional ban on serving more than two consecutive terms, President Evo Morales was allowed to run for a third term in 2014.
The constitutional court argued that the ban did not apply to Mr Morales' initial term because it had taken place before the new constitution came into effect.
Mr Morales will now not be able to stand in presidential elections in 2019.
But he is expected to continue serving out the remainder of his term, which ends in 2020.
When provisional results suggested a win for the "No" campaign, Mr Morales said that "the fight will continue" and his administration would follow through with its plans.
Critics within his party hope he will start training up a potential successor, while opposition politicians see it as a chance to challenge the governing parties.
Mr Morales said he had "lost a battle, but not the war".
There were celebrations in the eastern city of Santa Cruz, an opposition stronghold.
Many opposition politicians and some within Mr Morales's party said the outcome was a victory for democracy.
Former President Carlos Mesa said it showed that "no one is indispensable".
Samuel Doria Medina, who lost three times to Mr Morales in presidential elections said that Bolivia had won.
"They [the government] called this referendum and the people told them 'no'," he tweeted.
Mr Morales won the presidential election with 61% of the vote last year.
There is still widespread support for Mr Morales and his economic programme but many felt a change to the constitution was a step too far.
Some within the ranks of his own party also felt it was time for new, younger politicians to be given a chance to run.
The president's approval ratings were also hurt by recent allegations that he used his influence to favour a Chinese construction firm which employs his former girlfriend.
Mr Morales rejected the allegations and said he had nothing to hide. He ordered an investigation into how the contracts were awarded.

Bomb disposal officers were sent to Birmingham's Lee Bank area on Friday and nearby roads were closed and cordoned off.
The men, two aged 32 and 37 were arrested in Stoke-on-Trent and three others, aged 18, 24 and 28, were arrested in Birmingham.
Magistrates granted police a further seven days to question the men.
Detectives from the West Midlands Counter Terrorism Unit appeared before London's Westminster Magistrates' Court via video link on Saturday to submit their request for a warrant of further detention, a spokesman said.
The men were arrested on suspicion of being concerned in the commission, preparation or instigation of acts of terrorism.
Ch Supt Sue Southern, from West Midlands Police, said: "The arrests of the five men were intelligence led and our investigation continues at full pace."
A number of properties in the Stoke and Birmingham areas have been searched as part of the investigation.
The BBC understands the force was dealing with two suspect devices that were found at a business in Lee Bank on Friday.
Bolivians voted in a referendum on 21 February to decide whether to allow President Evo Morales to seek another term in office.
[NEXT_CONCEPT]
Police have been given more time to question five men arrested on suspicion of terrorism offences.