QUITO (Reuters) - Ecuador’s President Lenin Moreno agreed to swap a law that ended decades-old fuel subsidies for new legislation that will direct more resources to the needy, part of a deal he struck on Sunday with protest leaders to end a spate of violence that has roiled the Andean nation.

The announcement followed the first meeting between Moreno and indigenous leaders who have brought thousands of demonstrators to the streets of the capital Quito to demand he reinstate the subsidies.

For more than a week, Moreno had refused, defending the subsidy cuts as key to efforts to clean up Ecuador’s finances after signing a $4.2 billion loan deal with the International Monetary Fund.

But as clashes between police and demonstrators became more violent, Moreno said he agreed to get rid of a law that had become a target of protesters, Decree 883, by replacing it with a modified version.

“A solution for peace and for the country: the government will substitute Decree 883 for a new one that has mechanisms for directing its resources to the people who need it the most,” Moreno said on Twitter after the meeting in the town of Cumbaya.

In exchange, indigenous leaders, including chief indigenous organization Conaie, agreed to call off protests, said Arnaud Peral, the local representative of the United Nations and one of the mediators in talks.

“With this agreement, the protests and actions in all of Ecuador end,” Arnaud said as he announced a deal had been reached in broadcast comments.

Within seconds, fireworks were set off in Quito and cars honked their horns in celebration. Despite a citywide curfew, some residents waved Ecuador’s yellow, blue and red flag in public places to mark what appeared to be the end of more than a week of unrest.

Conaie said it was also celebrating “victory,” emphasizing the repeal of the fuel subsidy cuts. But it cautioned on Twitter that “this is not over until the agreement is fully realized.”

‘CONCEDING IS NOT LOSING’

It was unclear what specifically would be changed with a new law or how soon it would go into effect. But the government is committed to working with indigenous groups to design the new policy, said Peral.

Juan Sebastian Roldan, the presidency secretary, said representatives of the indigenous movement and the government would keep working late on Sunday to draft the new law.

“Conceding is not losing,” Roldan said at the end of the talks. “Here we are all conceding.”

Slideshow ( 19 images )

Earlier on Sunday, the highland city of nearly 3 million people resembled a war zone, with armored military vehicles patrolling some streets and sounds resembling explosions and shots ringing out. In the historic center, men took shelter behind makeshift barricades amid plumes of tear gas.

The militarization of the dispute has fueled criticism by human rights activists that the government’s approach was too heavy-handed and was only unleashing more violence.

At least seven people have been killed, several hundred wounded and more than 1,000 people arrested in protests since they began on Oct. 3, according to the ombudsman’s office, which monitors conflicts.

Slideshow ( 19 images )

Protesters had defied a curfew Moreno imposed on Quito and surrounding valleys on Saturday, escalating tensions further.

It was unclear whether Moreno would lift the curfew on Monday. He said on Saturday that it would remain in effect until further notice.

Moreno has blamed the unrest on “dark forces” linked to former president Rafael Correa, who is now a fierce critic of his government. Asked for evidence of that, Moreno’s government has pointed to attacks on the comptroller’s office, where documents related to a probe into the misuse of funds under Correa are stored.

Correa denies meddling and has called Moreno a sellout for turning to the right after being elected on a leftist platform.

Washington and other countries in South America had backed Moreno and condemned the violence.

A group of vandals set fire to the comptroller’s office for a second day in a row on Sunday, the interior minister said, and some 500 people had occupied a banned area in the city.

Indigenous protesters have also said that extremists from outside its ranks had been trying to instigate clashes, but it has denounced the government’s response as heavy handed.

Jaime Vargas, the head of Conaie, said dozens of its members and were still missing and hundreds in jail. “We don’t want more repression,” said Vargas.