President Lenín Moreno announced he would repeal fuel subsidy cuts, known as Decree 883, and replace it with the new legislation. The reversal came after 11 days of Indigenous-led protests.
It came after the two sides held talks brokered by the UN and the Roman Catholic Church.
The talks, which were broadcast live on state television, came after nearly two weeks of violent demonstrations.
President Lenín Moreno had imposed a curfew enforced by the military.
A joint statement said the government had withdrawn an order removing the fuel subsidies.
“With this agreement, the mobilizations… across Ecuador are terminated and we commit ourselves to restore peace in the country,” it said.
The two sides will now discuss a new law to ensure subsidies are not exploited by people who smuggle fuel to neighboring countries.
Government official Juan Sebastián Roldán said talks to start drafting the new law would start immediately.
“Conceding is not losing,” he said. “Here we are all conceding.”
A commission will also be set up to re-establish peace in the stricken Andean nation, with mediation by the Catholic Church, the UN and others.
The protest leaders in the negotiating room applauded while President Moreno gave no response.
This is undoubtedly a blow for him. Decree 883 was the main issue that prompted people to take to the streets in the first place and the president had repeatedly said there would be no going back on it.
However, given the intense and widespread protests over the past 12 days, in the end, he had little choice.
The calls for his resignation have been growing louder with each protest and President Moreno has looked increasingly vulnerable – especially since a number of demonstrators were killed in clashes with riot police.
The announcement after Sunday’s meeting sparked late-night celebrations in the capital Quito. People shouted “yes, we could” and “the people, united, will never be defeated”.
Fireworks were set off and car drivers honked their horns.
A resident, Cristina Vasquez, told Reuters news agency she wanted to praise the contribution of Ecuador’s indigenous people, who were at the forefront of the protests: “More than a celebration it is an appreciation of the indigenous people who represented us and helped because this is a win for everyone.”
The indigenous umbrella group Conaie called on its members to come together to “clean the streets” of barricades and debris after the damage caused by 12 days of
The protests began after the government announced an end to fuel subsidies as part of public spending cuts agreed with the International Monetary Fund (IMF) in return for a loan.
Mr Moreno said the subsidies, which cost the government $1.3bn (£1bn) annually and were introduced in the 1970s, were no longer affordable. Eliminating them was part of his plan to shore up Ecuador’s flagging economy.
But petrol prices soared and thousands took to the streets.
Clashes between protesters and riot police led Mr Moreno to declare a two-month national emergency. He accused his opponents of attempting a coup.
As the violence grew worse Mr Moreno temporarily moved government operations from Quito to the port city of Guayaquil.
Seven people died during the protests, more than 1,300 were injured and 1,152 were detained, according to official figures.
Protesters also took dozens of officers hostage in various locations throughout the country.
Indigenous-led protests have toppled three presidents in the past few decades.