The preliminary results showed that Morales, South America’s longest-serving leftist leader, would have to go to a December 15 run-off with Mesa.
Morales is seeking a controversial fourth term.
Elected Bolivia’s first indigenous president in 2005, Morales has won his previous elections in the first round, never having to contest a run-off.
The former coca farmer and leftist union leader has led the poor but resource-rich Latin American country for the past 13 years, though his popularity has waned amid allegations of corruption and authoritarianism.
He will face a stiff challenge from Mesa, a 66-year-old former president who led Bolivia from 2001-2005.
Mesa celebrated “an unquestionable triumph” in getting to the second round, amid cheers from his supporters at his La Paz headquarters.
Morales welcomed his first-round win, telling cheering crowds “we have won again, really, it is something historical, unforgettable”.
South Korean-born evangelical pastor, Chi Hyun Chung, was the surprise package of the election, polling strongly to finish in third place with 8.7 percent.