(Recasts after deal reached)
By Alexandra Valencia
QUITO, Oct 13 (Reuters) - Ecuador's President Lenin Moreno said he struck a deal late on Sunday with indigenous leaders who have mobilized thousands of protesters against a decree that slashed fuel subsidies, agreeing to replace it with one that does more to help the most needy.
In exchange, the indigenous leaders agreed to immediately call off protests that have rocked Quito and led Moreno to impose an indefinite curfew in the capital, said mediator Arnaud Peral, the representative of the United Nations in Ecuador.
Fireworks went off in Quito and cars honked their horns in celebration after Arnaud announced an agreement had been reached following three hours of televised negotiations.
"A solution for peace and for the country: the government will substitute Decree 883 for a new one that has mechanisms for directing the resources to the people who need it the most," Moreno later said on Twitter.
It was unclear how soon the law might be replaced.
Juan Sebastian Roldan, Moreno's secretary of government, said that both sides planned to continue talking late on Sunday to start drafting the new law.
"Conceding is not losing," Roldan said in broadcast comments. "Here we are all conceding."
Earlier on Sunday, clashes between police and protesters dragged into a 12th day as many demonstrators defied the military-enforced curfew Moreno imposed.
"With this agreement, protests and actions across Ecuador end," said Peral, the mediator.
The South American trade bloc, Mercosur, along with other countries in the region had backed Moreno and condemned the violence.
The unrest has been the worst in the small South American country in more than a decade and the latest flashpoint of opposition to the International Monetary Fund in Latin America.
Moreno, who took office in 2017, signed a $4.2 billion deal with the IMF earlier this year, angering many of his former supporters who voted for him as the left-leaning successor of his former ally, Rafael Correa.
Moreno has denied the fuel subsidy cuts was imposed by the IMF. He had repeatedly refused to bring back the subsidies, saying they were a key part of his bid to clean up the country's finances.
The unrest first erupted with protests led by truck drivers. Indigenous demonstrators later took the lead, although they have said extremists from outside their ranks had sought to instigate clashes.
At least seven people have been killed, several hundred wounded and more than 1,000 people arrested in the unrest since it began on Oct. 3, according to the ombudsman's office, which monitors conflicts. (Reporting by Alexandra Valencia; Additional Reporting and Writing By Mitra Taj; Editing by Daniel Wallis, Peter Cooney and Raju Gopalakrishnan)
Our Standards: The Thomson Reuters Trust Principles.