Moreno, the designated heir to President Rafael Correa's "21st-century socialism," had 51.07 percent of the vote to 48.93 percent for ex-banker Lasso, with 94.2 percent of districts reporting, said the National Electoral Council.
Lasso said his campaign had evidence of an attempt to rig the results.
"We are going to defend the will of the Ecuadoran people in the face of an attempted fraud that aims to install what would be an illegitimate government," he said, setting up what could be a long and ugly fight.
It may also decide the fate of WikiLeaks founder Julian Assange, who has been holed up in Ecuador's London embassy since 2012.
More From This Section
Both candidates claimed victory on the basis of conflicting exit polls.
"We will continue this process that has changed Ecuadorans' lives, especially for the poorest citizens," Moreno, a wheelchair user paralyzed in a 1998 carjacking, triumphantly told supporters, before launching into an exuberant victory party at which he regaled the crowd with his singing.
Angry protests followed the first-round vote on February 19, when Moreno came close to winning outright and Lasso supporters cried fraud.
Correa presided over an economic boom that has recently gone bust.
"It's a decisive moment because we've had a conservative reaction in recent years," the outgoing president said after casting his ballot, adding that "the whole world is watching."
In Latin America, where a so-called "pink tide" of leftist leaders has been ebbing, the vote is seen as crucial.
Boosted by high prices for its oil exports, Ecuador registered solid economic growth averaging 4.4 percent per year during the first eight years of Correa's presidency, before tipping into recession in mid-2015.