An indigenous man holds up a crucifix and a national flag as people celebrate outside the Casa de la Cultura in Quito Sunday after Ecuador’s president and indigenous leaders reached an agreement to end violent protests. Photo: AFP

Ecuador’s president and indigenous leaders reached an agreement on Sunday to end nearly two weeks of violent protests against austerity measures adopted to obtain a multibillion dollar loan from the International Monetary Fund (IMF).

The demonstrations have left seven people dead and were sparked when President Lenin Moreno scrapped fuel subsidies to obtain a $4.2 billion loan from the IMF, causing prices to double.

Moreno met with Jaime Vargas, the head of the indigenous umbrella group CONAIE, for four hours of talks in the capital Quito broadcast live on state television.

“With this agreement, the mobilizations… across Ecuador are terminated and we commit ourselves to restoring peace in the country,” said a joint statement, adding the government had withdrawn an order that removed fuel subsidies.

Thousands flooded into the streets of Quito shortly after the announcement, waving the national flag, honking horns and setting off fireworks in celebration.

The statement was read by an official from the United ­Nations, which mediated the talks along with the Catholic Church.

“The measures applied in all our territories are lifted,” confirmed Vargas, referring to roads and oil facilities in the Amazon blocked by protesters for almost two weeks. Those actions suspended the distribution of almost 70 percent of the country’s crude oil.

Indigenous groups make up a quarter of Ecuador’s 17.3 million people. Thousands who had traveled from disadvantaged communities across the Amazon and the Andes to spearhead the protests in ­Quito started to head home after the deal was announced.

“Indigenous brothers, I have always treated you with respect and affection,” Moreno said. “It was never my intention to affect the poorest sectors.”

Moreno had previously declared a curfew and placed Quito under military control to quell the unrest.

On Sunday, violent clashes continued before the talks began as police fought to disperse protesters who tried to put up a barricade of debris from Saturday’s unrest.

The violence forced Moreno to relocate his government to Ecuador’s second city, Guayaquil, and hit the oil industry hard with the energy ministry suspending more than two-thirds of its distribution of crude oil.

CONAIE had previously rejected an offer of dialogue but reversed course Saturday.

UN Secretary-General Antonio Guterres earlier called on all groups “to commit to inclusive and meaningful talks, and to work in good faith towards a peaceful solution.”