When farmer Luiz Martins Neto first moved to Sao Felix do Xingu a quarter of a century ago, the area had virgin forest, gold and a reservation for the local indigenous people.
"They used to say it was the best place to live," he said.
But like many others, he created his first fazenda—coffee plantation—with slash and burn techniques, helping to destroy his pristine surroundings.
"In those days, the more you cleared the forest, the better your life was and the more land you acquired," the 54-year-old said.
This was long the prevailing view in Brazil's vast Amazon region, particularly during the 1964-85 military dictatorship.
But, decades later, the town in the northern state of Para is turning its back on the destructive ways of the past and trying to save what it has left.
Today, Neto's farm is part of a model agribusiness project that makes use of deforested land and does not encroach on the remaining forest.
"One learns how to do things right," he said, flashing a proud smile under his straw hat.
A new forestry law took effect last October, limiting the use of land for farming and mandating that up to 80 percent of privately-owned acreage in the Amazon rainforest remains intact.
More than 60 percent of Brazil's 8.5 million square kilometers (3.3 million square miles) is covered in forest, but two-thirds of it is either privately owned or its ownership is undefined.
On Neto's small farm, pastures and the giant trunk of a dead cashew nut tree are visible signs of past deforestation.
The practice is a big part of the history of this town of 90,000 half occupied by indigenous lands and parks.
Mining and cattle ranching are other major activities that have left their mark, attracting several multinational companies.
"The arrival of the white man was like a river wave: It keeps advancing, advancing but does not recede," said Amauri Bepnhoti Atydjare, a member of the Kayapo ethnic group.
Kayapo territory is a big mantle of forest dotted by small hamlets built around a square.
A decade ago, trucks loaded with timber rumbled through the town and the skies were blackened by smoke from forest-clearing fires.
"Sao Felix do Xingu was a champion of deforestation," said Mayor Joao Cleber.
"In 2008, the government drew up a list of towns which deforested the most and we were number one," he added.
"But now we are the ones who have reduced deforestation the most, from 2,500 square kilometers (965 square miles) in 2000, to 169 square kilometers (65 square miles) last year."
The drive to reverse deforestation followed strong pressure from the federal government.
Five years ago, Brasilia made an international commitment to stem rainforest destruction and cut off access to credit for towns deemed the worst offenders.
Companies that bought production from deforested areas were also penalized.
"The pressure on towns and the industry was key as this led to a pact between the meat industry, city hall and rural producers," said Ian Thompson, head of the Amazonia program at The Nature Conservancy (TNC). These agreements are monitored by public prosecutors.
"The cattle industry occupies a good part of the territory and is to blame for a major part of the deforestation, but with very low productivity: one cow per hectare," Thompson said.
"With better methods, we are trying to double production without deforesting more."
Reversing course is already paying off.
Sao Felix is currently experiencing a cocoa boom as the native Amazonian species helps regenerate deforested areas.
One model project, backed by US agribusiness giant Cargill, involves cocoa cultivation on 100 small production farms.
"Cargill is interested in large-scale and sustainable production and we are guaranteed an income while we regenerate degraded areas" to be in conformity with the new forestry law, said Ilson Martins, president of the local cocoa cooperative Cappru.
"We want to give the region another image. The consumer does not want products that create deforestation," said Wilton Batista, president of the Rural Producers' Union.
But keeping deforestation in check is an uphill battle in Sao Felix and the rest of the Amazon due to the size of the area and its difficult access.
In this town of more than 84,000 square kilometers (32,432 square miles), with a little more than 80 percent of rainforest still intact, indigenous lands divide the territory.
At city hall, experts are analyzing satellite data to determine exactly where deforestation is taking place—and who is responsible.
Despite the goodwill and progress, economic challenges remain.
"You have to find a way to provide an income to 25 million people who live in the Amazon or otherwise we will face chaos," said the local agricultural secretary, Denimar Rodrigues.
Sustainable production requires technical assistance and investment, he said.
Amazonian deforestation reached an alarming peak of 27,772 square kilometers (10,722 square miles) lost per year in 2004 and led Brasilia to pledge to reduce it by 80 percent by 2020.
Last year, deforestation fell to 4,751 square kilometers (1834 square miles), it lowest level in decades.
Explore further: Brazil sends more inspectors to Amazon rainforest