The United States and China announced a joint agreement Wednesday to "enhance ambition” on climate change, saying they would work together to do more to cut emissions this decade while China committed for the first time to reduce methane, a potent greenhouse gas.

The pact between the world’s two biggest polluters came as a surprise to the thousands of attendees gathered here for a United Nations climate summit. China and the United States, rivals that face growing tensions over trade, human rights and other issues, spoke as allies in the fight to keep global warming to relatively safe levels.

"We both see the challenge of climate change is existential and a severe one,” said Xie Zhenhua, China’s climate change envoy. "As two major powers in the world, China and the United States, we need to take our due responsibility and work together and work with others in the spirit of cooperation to address climate change.”