Should Ecuador continue drilling in one of the most biodiverse corners of the Amazon or should it keep the oil underground? On Sunday, its people will decide in a binding referendum that landed on the ballot after a decade-long fight by young activists.

As the world faces twin ecological crises of climate change and ecosystem collapse, the vote will determine what one country’s citizens are willing to give up to protect the planet.

The section of jungle on the ballot Sunday, part of Yasuní National Park, is one of the most ecologically rich places on Earth and home to Indigenous people who want no contact with outsiders. The vote comes as the planet swelters under record-breaking heat and scientists warn that the Amazon rainforest is dangerously close to a tipping point that could turn it into grasslands.

But oil is Ecuador’s most important export and the government is campaigning for drilling to continue. According to official estimates, the country stands to lose $1.2 billion in revenue a year if the oil is left underground.

“It’s historic,” said Pedro Bermeo, one of the founding members of Yasunidos, the group behind the referendum. “We’re democratizing environmental politics.”

Adding to the tension in Ecuador is a worsening political and security crisis. The Sunday election was called in May after President Guillermo Lasso, facing impeachment proceedings, invoked his right to dissolve Congress. Then, last week, one of the presidential candidates, Fernando Villavicencio, was assassinated.

It’s unclear how the political turbulence will affect the referendum, but a recent survey by Comunicaliza, a polling firm based in Quito, the capital, suggested that 35 percent of voters want to stop the drilling, 10 percentage points more than those backing oil. Many said they were still undecided.

The vote is the culmination of a groundbreaking proposal suggested almost two decades ago when Rafael Correa, who was president of Ecuador at the time, tried to persuade wealthy nations to pay his country to keep the same oil field in Yasuní untouched. He asked for $3.6 billion, or half of the estimated value of the oil reserves.

Mr. Correa spent six years in a campaign to advance the proposal but never managed to persuade wealthy nations to pay. Many young Ecuadoreans, though, were persuaded. When Mr. Correa announced that the proposal had failed and that drilling would begin, many started protesting.

It was during those days that Antonella Calle, 19 at the time, along with other young people and environmentalists, decided to keep fighting as part of a new organization called Yasunidos.

Mr. Correa scoffed at the opposition to drilling. “Gather the signatures and let’s go to a referendum and we will win again,” he said.

Yasunidos recruited around 1,400 volunteers to walk the streets and knock on doors across the country. In a six-month whirlwind, they collected more than 757,000 signatures, almost 200,000 more than required to trigger a referendum.

Polls from around that time suggested that more than 90 percent of Ecuadoreans would have voted to keep the oil underground. But the Correa administration created a task force to verify signatures and voided more than half of them. Even Ms. Calle and Mr. Bermeo’s signatures were deemed invalid.

“It was a very tough blow,” Ms. Calle said. “They were calling us liars.”

So, Yasunidos started a decade-long legal struggle to get the referendum in front of voters. Finally, in May, the Supreme Court ordered the government to include the measure in the upcoming election.

The referendum also builds on work by Indigenous groups in Ecuador. In 2019, for example, after a court battle, a Waorani Indigenous community managed to block oil development on its land.

“Mother Earth isn’t waiting for us to save her,” said Nemonte Nenquimo, a leader who pushed that effort. “Mother Earth is waiting for us to respect her. If we don’t respect her, Mother Earth herself will swallow humanity.”

If Yasunidos wins, the state oil company, Petroecuador, will have roughly a year and a half to wind up its operations in the area, known as the Ishpingo-Tambococha-Tiputini Oil Field. According to Andrés Martínez Moscoso, a law professor at the San Francisco de Quito University, neither the president, Congress nor a new referendum could undo Sunday’s results.

But by now, Petroecuador has invested more than $2 billion to extract oil in the parcel. The company said it would have to spend an additional half-billion if it was forced to dismantle miles of pipelines, close hundreds of oil wells and disassemble a dozen platforms.

Executives at Petroecuador say the company’s impact on biodiversity is restricted to 80 hectares, or less than 200 acres, a small fraction of the I.T.T. area, and monitored by scientists.

“In terms of area, our footprint is very, very low,” Armando Ruiz, who oversees the company’s environmental policies, said. For Ecuador’s sacrifice to make a difference in the battle against climate change, he said, “the whole world, all governments of this planet, would need to have the same commitment.”

Petroecuador recorded a series of videos with the leaders of some Indigenous communities within the I.T.T. area who said they wanted drilling to continue. But major Indigenous organizations in Ecuador are asking voters to choose an end to drilling. Even the Waorani Nationality of Ecuador, a government-recognized group that has partnered with oil companies in the past, is now asking Ecuadoreans to vote to stop drilling in this case.

Fifty years of oil drilling “has simply brought us poverty, problems, diseases, conflict and death,” said Juan Bay, the group’s president. “The people who benefited were outsiders.”