Political analysts said it was unlikely right-wing candidate Guillermo Lasso would succeed in overturning the result, given the grip that outgoing President Rafael Correa's camp has on the levers of power.
Moreno, 64, a wheelchair user and champion of disability rights, is seen as a more moderate successor to Correa, a radical economist who declared "21st-century socialism" in Ecuador and regularly berated the United States.
Moreno is known for cracking jokes and reaching out to opponents.
The election was closely watched as a barometer of the political climate in Latin America, where more than a decade of leftist dominance has been waning.
It was also a clutch day for WikiLeaks founder Julian Assange, who faced a threat by Lasso to expel him from his refuge in Ecuador's London embassy.
With 99.35 percent of ballots counted from Sunday's vote, the National Electoral Council said Moreno won 51.17 percent against 48.83 percent for ex-banker Lasso.
"I'm going to be the president of all Ecuadorans. Yes, all, but especially the poor," Moreno said in a speech to some 2,000 supporters outside the presidential palace.
- Protesters cry fraud -
Lasso vowed to challenge the result, saying his campaign had "ample evidence" of irregularities.
"We cannot recognize these illegitimate results," he wrote on Twitter.
"We will exhaust all political and legal avenues in Ecuador and internationally to make sure the will of the people, who demanded change, is respected."
Some Lasso supporters protested outside election offices in Quito and other cities.
The electoral authority was under tight police guard Monday.
Argentina, Brazil and Peru have all shifted to the right in recent months as the region has sunk into recession.
Lasso had vowed to undo Correa's legacy, after the country's economic boom went bust.
Boosted by high prices for its oil exports, Ecuador registered solid economic growth during the first eight years of Correa's presidency, before tipping into recession in 2015.
Correa won loyal fans among the poor with generous social benefits that helped slash the poverty rate in this country of 16 million people.
But he has also faced accusations of corruption and squandering the windfall of the oil boom.
"Moreno will face two challenges: starting his term in government with diminished popularity (for his side) and with an economy that is going through lean times," political scientist Esteban Nicholls from the Andean University of Ecuador told AFP.
Protests from Lasso's camp would only add to Moreno's headaches.
But his victory will likely hold, said Risa Grais-Targow of the Eurasia Group consultancy.
"The government enjoys a significant institutional advantage, with the National Electoral Council, the courts, and the legislature all firmly under its control," she said in a note.
If his victory is confirmed, Moreno will be the first wheelchair user to be elected Ecuador's president, and one of few such leaders in world history. His legs have been paralyzed since he was shot in a carjacking in 1998.
- Assange wades in -
Lasso had vowed that within 30 days he would revoke the political asylum Ecuador granted to Assange in 2012 to help him avoid extradition to Sweden over a rape allegation.
The Australian denies the allegation and says he fears Sweden would send him to the United States to face trial for leaking hundreds of thousands of secret US military and diplomatic documents in 2010.
Assange commented on the election result in a provocative Twitter message, referring to accusations from Correa's camp that Lasso had money stashed in offshore accounts.
"I cordially invite Lasso to leave Ecuador within 30 days (with or without his tax haven millions)," he wrote.