Ecuador began counting the cost on Monday of 12 days of indigenous protests against fuel hikes that left eight demonstrators dead and severely dented Ecuadorian President Lenin Moreno’s austerity programme.

Moreno and indigenous leaders reached an agreement on Sunday after the president pledged to withdraw subsidy cuts, known as Decree 883, that had more than doubled fuel prices.

The cuts were part of an austerity package to obtain a $4.2 billion loan from the International Monetary Fund (IMF) to shore up the oil exporter’s brittle economy.

Moreno wrote on Twitter that the original plan would be replaced by new measures that “contain mechanisms to focus resources on those who need them most”.

“These days should teach us to value peace, stability, security,” Moreno said in a televised statement on Monday evening.

Under the deal, indigenous umbrella group Conaie called off protests that brought chaos to the capital and forced Moreno to relocate his government hundreds of kilometres away to the second city Quayaquil.

Thousands of indigenous people began leaving Quito on Monday in convoys of trucks, returning to communities in the Andes and the Amazon rainforest that they left more than a week ago to vent their outrage at the increases.

The ombudsman’s office reported that 1,340 people had been injured in the protests, some of whom were in critical condition, while 1,192 people had been detained.

The protests caused an estimated $1.5 billion in losses, according to the head of the Ecuadorian Business Committee Patricio Alarcon.

Sunday’s breakthrough after four hours of talks was announced by an official from the UN, which mediated negotiations along with the Catholic Church.

The top US diplomat for Latin America, Michael Kozak, said the agreement “shows the power of peaceful dialogue and will help bring stability back to the country and prosperity to its people”.

Venezuelan President Nicolas Maduro, whom Moreno accused of colluding with ex-president Rafael Correa to stoke indigenous unrest, welcomed “a historic victory over the IMF”.

“I congratulate the Ecuadoran people because they have achieved a historic victory over the IMF, by getting the derogation of Decree 883,” Maduro said on Twitter.

Maduro and the Belgium-based Correa scoffed at Moreno’s claims that they tried to mount a coup to depose him, but Moreno wasted no time in moving against Correa allies.

Police on Monday arrested the governor of Quito’s surrounding province of Pichincha, Paula Pabon.

They also raided the house of former lawmaker Virgilio Hernandez, while another lawmaker, Gabriela Rivadeneira, took refuge in the Mexican embassy in Quito on Saturday.

“Peace has been restored and put a stop to the Correa-ist coup,” Moreno said on Twitter.

However, the political, economic and social recovery is likely to be long and difficult.

The government had slashed fuel subsidies to save $1.3 billion a year but will now have to find the savings elsewhere.

“Ecuador has to fulfil its commitments to the IMF because nobody is going to lend to it if they want to continue spending and want to continue living on debt, which is the strategy that has been applied since 2014,” analyst Alberto Acosta Burneo said.

“It’s going to be very difficult to recover from the fracture caused by the protests,” warned indigenous expert Pablo Romero.

Romero, of Quito’s Salesian University, said the indigenous people – 25 per cent of Ecuador’s 17.3 million population – had won a “symbolic” victory, but the protests had exposed deep rifts and “racism” in the country.

The protest had cost all sides dearly, he said.

“The government, because all its weaknesses were exposed; the Conaie, because divisions in its leadership became apparent; and the country itself,” Romero said.