WASHINGTON — After more than two decades of trying but failing to forge a global pact to halt climate change, United Nations negotiators gathering in South America this week are expressing a new optimism that they may finally achieve the elusive deal.

Even with a deal to stop the current rate of greenhouse gas emissions, scientists warn, the world will become increasingly unpleasant. Without a deal, they say, the world could eventually become uninhabitable for humans.

For the next two weeks, thousands of diplomats from around the globe will gather in Lima, Peru, for a United Nations summit meeting to draft an agreement intended to stop the global rise of planet-warming greenhouse gases.

The meeting comes just weeks after a landmark announcement by President Obama and President Xi Jinping of China committing the world’s two largest carbon polluters to cuts in their emissions. United Nations negotiators say they believe that advancement could end a longstanding impasse in the climate talks, spurring other countries to sign similar commitments.