HANGZHOU, China — President Obama and President Xi Jinping of China formally committed the world’s two largest economies to the Paris climate agreement here on Saturday, cementing their partnership on climate change and offering a rare display of harmony in a relationship that has become increasingly discordant.
On multiple fronts, like computer hacking and maritime security, ties between China and the United States have frayed during the seven and a half years of Mr. Obama’s presidency. The friction has worsened since the ascension of Mr. Xi as a powerful nationalist leader in 2013.
Yet the fact that he and Mr. Obama could set aside those tensions to work together yet again on a joint plan to reduce greenhouse gases attests to the pragmatic personal rapport they have built, as well as to the complexity of the broader United States-China relationship, a tangle of competing and congruent interests.
At a ceremony in this picturesque lakefront city, the two leaders hailed the adoption of the Paris agreement as critical to bringing it into force worldwide. Though widely expected as the next step in the legal process, the move could provide a boost to those who want to build momentum for further climate talks by bringing the December accord into effect as soon as possible.
Countries accounting for 55 percent of the world’s emissions must present formal ratification documents for that to happen, and together, China and the United States generate nearly 40 percent of the world’s emissions.
“Despite our differences on other issues, we hope our willingness to work together on this issue will inspire further ambition and further action around the world,” Mr. Obama declared.
Mr. Xi praised the Paris agreement as a milestone, adding, “It was under Chinese leadership that much of this progress was made.”
From the moment he stepped off Air Force One on his final visit to Asia as president, Mr. Obama confronted a resurgent China, undaunted by his efforts to restore America’s presence in the region and poised to capitalize on his troubles in winning congressional passage of his ambitious regional trade agreement, the Trans-Pacific Partnership.
Mr. Obama’s chaotic welcome on the tarmac captured the mood on the eve of the G20 summit. There were arguments at the airport between White House aides and Chinese security officials who tried to keep back reporters. Shouting matches also broke out between Mr. Obama’s staff and guards over how many people were allowed into the state guesthouse where he and Mr. Xi later met.
In recent years, the Obama administration has sought to highlight cooperation on climate change, but China’s commitments, first made in 2014, have been less a concession to American pressure than a restatement of its own goals. They include a promise for China’s carbon emissions to reach a plateau or decline “around 2030,” but without any specific target for reductions like those Mr. Obama pledged for the United States (25 percent of 2005 levels by 2025). That means China has plenty of room to continue burning fossil fuels to power its economy.
“The story of the past eight years is not mainly the pivot or the rebalance; it is the very substantial increases in Chinese capacities since 2008,” said Jeffrey A. Bader, who helped formulate Mr. Obama’s Asia strategy as his chief China adviser in the first term.
“How has the U.S. dealt with that?” he added. “How has the U.S. confronted that?”
The Obama administration has experimented with a variety of approaches: pledging to respect China’s “core interests” in 2009; shifting in 2011 to a more assertive stance — verging on containment — as Mr. Obama articulated his pivot to Asia; then resisting China’s proposal in 2012 to embark on a new model of great-power relations.
To some critics, that was an inconsistent strategy — one that alternately cheered or sowed anxiety among American allies, and likewise alienated or emboldened China. Under Mr. Xi’s leadership, China has made aggressive claims to shoals and reefs in the South China Sea, picking fights with neighbors like the Philippines and Vietnam.
“This back and forth has, I think, exacerbated what was already a growing problem with a China that was already more assertive in the context of the financial crisis,” said Michael J. Green, who was the chief Asia adviser on the National Security Council in the George W. Bush administration and is now at the Center for Strategic and International Studies.
But the administration’s defenders, like Mr. Bader, argue that Mr. Obama was merely following in the tradition of presidents, Democrat and Republican alike, dating back to Richard M. Nixon. They have tried to manage China’s rise by drawing it into the international system and prodding it to accept rules of the road in trade, navigation and other areas.
However, China has dismissed a recent ruling by an international tribunal in The Hague that rebuked its aggressive reclamation of land on disputed shoals in the South China Sea and invalidated its historical claims to a large swath of those waters.
Mr. Obama was expected to press Mr. Xi to abide by the ruling in a meeting after the climate ceremony, less because he expected the Chinese leader to reverse himself than because the ruling is a vital predicate for undermining the legitimacy of China’s imperial claims.
Still, even after Mr. Obama deployed Navy ships to the Pacific, sent Marines to Australia and paid for greater access to the military bases of an old ally, the Philippines, China now has greater control of the South China Sea than it enjoyed at the start of his presidency.
Meanwhile, Mr. Obama’s struggle to pass the Trans-Pacific Partnership has stoked doubts about America’s economic staying power. The 12-nation pact, which excludes China, has become the centerpiece of the pivot to Asia. But it has fallen victim to election-year politics at home and now seems unlikely to pass, even in a lame-duck Congress.
Some of the nations that signed on, particularly Japan — America’s most important Asian ally and a nervous neighbor of China — have made political sacrifices by opening markets in order to meet the standards demanded by the United States. Failure to pass the trade pact, Asian diplomats and analysts said, would leave them feeling burned.
“The Japanese, living in an uncertain world, depending on an American nuclear umbrella, will have to say on trade: ‘The Americans could not follow through,’” Prime Minister Lee Hsien Loong of Singapore said during a recent visit to Washington, standing next to Mr. Obama. “If it’s a matter of life and death, whom do I have to depend on?”
Mr. Obama and his chief trade negotiator, Michael B. Froman, understand the stakes. They plan a full-court press to sell the pact on this presidential trip — characterizing its passage as a litmus test of American leadership — in hopes that the message will echo back home.
“We are one vote away from cementing our leadership in Asia or ceding it to China,” Mr. Froman said in an interview in Beijing. “I’m not sure Congress wants to hand the keys to the castle to China.”
The Trans-Pacific Partnership is viewed in Asia as the handiwork of Mr. Obama in particular, especially since the Democratic presidential nominee, Hillary Clinton, who repeatedly backed it when she was Mr. Obama’s secretary of state, has renounced her support. If Congress fails to pass it, Asian diplomats said, China will emerge as a victor.
“It will be a political disaster and play into the Chinese narrative that China is a geopolitical fact, whereas the U.S. presence is the consequence of a geopolitical calculation which could change and thus is not reliable,” said Bilahari Kausikan, the ambassador at large for Singapore.
In practical terms, the United States would lose the chance to shape the economic future of the region, allowing China to forge ahead with its “Sino-centric economic order,” which includes a multibillion-dollar project to build a new Silk Road linking Asia to Europe.
Mr. Bader is among several American officials who are guardedly confident that the next presidential administration will find a way to win approval for the Trans-Pacific Partnership, perhaps by adding side agreements on contentious points. But he expressed concern that the South China Sea would be a chronic source of friction.
“The situation hasn’t stabilized,” Mr. Bader said. “Achieving that is beyond the capacity of the U.S. alone.”
China has extended its military reach there by building artificial islands with airfields, facilities that American commanders have said they regard as military bases. Although China appears to be taking stock of the situation since the unfavorable ruling in The Hague, Chinese military officials warn that they will continue with their building program in the waterway.
“China will never stop our construction,” the head of China’s navy, Adm. Wu Shengli, said in July.
Last month, China took delivery of a dredger, one of the biggest in its inventory, from a Dutch shipyard. The vessel would be suitable for dredging at Scarborough Shoal, a disputed reef 150 miles from the Philippines.
China, some academics say, plans to create an extremely large artificial island that would complete a strategic triangle of bases in the sea.
“Obama is seen as reluctant to push back,” said Alan Dupont, a former defense intelligence analyst for the Australian government. “He has allowed China to militarize the islands in the South China Sea. The United States hasn’t put it at the top of its list.”
To reassure its allies, Mr. Dupont said, the United States would have to reinforce its military presence in the Pacific even further than it has under Mr. Obama’s pivot, or rebalance, as it has also been called.
“There has to be a rebalance plus,” he said.