President Biden and his allies spent much of the G7 summit in Hiroshima, Japan, announce new weapons package for Ukraine, including a path to provide F-16 fighter jets. They spent hours discussing strategy with President Volodymyr Zelensky for the next phase of a hot war started by Russia.

So it was easy to miss Mr Biden’s prediction on Sunday of a coming “thaw” in relations with Beijing as both sides move beyond what he called the “stupid” Chinese action of sending a giant surveillance balloon over the US, just the latest in a series incidents that have fueled what appears to be a decline toward confrontation.

It is far too early to tell whether the president’s optimism is based on the tacit signals he has received in behind-the-scenes meetings with the Chinese government in recent weeks.

Mr. Biden’s own aides see a battle going on in China between factions that want to reopen the economic relationship with the United States and a much more powerful group aligned with President Xi Jinping’s emphasis on national security over economic growth. As this weekend showed, China is extremely sensitive to any suggestion that the West is mounting a challenge to Beijing’s growing influence and power.

So if Mr. Biden is right, it may take a while for the ice to melt.

Bringing a new, unified set of principles from major Western allies and Japan on how to protect their supply chains and their key technology from Beijing – included in the meeting’s final communiqué – China erupted in outrage.

Beijing denounced what it portrayed as a cabal seeking to isolate and weaken Chinese power. The Japanese ambassador in Beijing was called in for a reaming out, and China moved to ban products from Micron Technology, an American chipmaker, on the grounds that its products posed a security risk to the Chinese public. It seemed to be exactly the kind of “economic coercion” that world leaders had just promised to resist.

Mr. Biden often says he has no desire to see another Cold War start with China. And he points out that the economic interdependencies between Beijing and the West are so complex that the dynamic between the two countries is completely different from what it was when he first immersed himself in foreign policy 50 years ago as a newly elected senator. .

The harmony in Hiroshima to develop a joint approach, and the explosions from Beijing that followed, suggested that Mr. Biden had made progress on one of his top foreign policy priorities despite underlying tensions among the allies. Instead of dwelling on their differences, the leaders of the major industrial democracies lined up their stance on China in a way that Beijing apparently saw as potentially threatening, some analysts noted after the meeting.

“One indication that Washington would be pleased is that Beijing is so unhappy,” said Michael Fullilove, executive director of the Lowy Institute, a research group in Sydney, Australia.

Matthew Pottinger, a former deputy national security adviser to President Donald J. Trump and the architect of that administration’s approach to China, agreed. “The fact that Beijing was so sensitive to the G7 statements is an indicator that the allies are moving in the right direction.”

Mr Biden and the other leaders of the G7 – which includes Britain, Canada, France, Germany, Italy and Japan – wrote their first joint statement of principles on how to resist economic blackmail and deter China from threatening or invading Taiwan, while seeking to to assure Beijing that they did not seek confrontation.

The communique pressed China on the usual points of stress, including its military buildup in the South China Sea and widely documented human rights abuses against Uyghurs and other Muslims in Xinjiang. Four months after the US began quietly distributing intelligence to European allies suggesting China was considering sending weapons to Russia to fuel its fight in Ukraine, the document appeared to be a warning to Beijing against pushing its “no borders” relationship with Russia also far.

Yet the democracies also left the door open to improving relations with Beijing by making clear they were not seeking a Cold War containment strategy against the world’s rising economy, even as they seek to cut China off from key technologies — including European-made machinery essential to producing the most advanced semiconductors in the world.

“Our policy approaches are not designed to harm China, nor do we seek to oppose China’s economic progress and development,” the communique said. “A growing China that follows international rules would be of global interest. We are not decoupling or turning inward. At the same time, we recognize that economic resilience requires reduced risk and diversification.”

“Risk Free” is the new term of art, coined by the Europeans, to describe a strategy to reduce their dependence on Chinese supply chains without “decoupling,” a much stricter separation of economic relationships. Mr. Biden’s team has embraced the phrase, and the strategy — meant to sound self-protective rather than punitive — has become a staple of the latest conversation about how to deal with Beijing. Jake Sullivan, the national security adviser, talks about “building a high fence around a small farm” to describe the protection of key technologies that could bolster China’s rapid military buildup.

But what looks like risk mitigation to the US and Europe may look like a neatly worded containment strategy in Beijing.

The consensus reached in Hiroshima came after what Michael J. Green, a former top Asia adviser to President George W. Bush, called “a series of diplomatic wins for the United States and losses for China.” He has been working behind the scenes to promote a rapprochement between South Korea and Japan, and plans to integrate Japan into an advisory group on nuclear strategy and deterrence announced during a state visit last month by Yoon Suk Yeol. If successful, it would create a much tighter nuclear alliance in China’s neighborhood.

“From Beijing’s perspective, this has been a week of even closer alignment between the other powers in the region with the United States,” said Mr. Green, now CEO of the United States Studies Center at the University of Sydney.

China pushed back hard. In a statement over the weekend, it accused the G7 of “obstructing international peace,” “falsifying and attacking China” and “grossly interfering in China’s internal affairs.” On the same day, it accused Micron of “relatively serious cybersecurity issues” that could threaten national security, the same argument the US makes about TikTok and Huawei.

Despite the common ground in Hiroshima, Mr. Biden’s decision to canceling the second half of his trip to the Pacificincluding a stop in Papua New Guinea, so he could rush home to deal with domestic spending and debt negotiationswas taken as a setback in competition with China.

Now the question is whether Mr. Biden can quietly rebuild a relationship with Xi that appeared to turn around last fall, after their first face-to-face meeting.

Mr. Biden referred to the spy balloon incident in interesting ways on Sunday.

“And then this silly balloon carrying spy equipment for two freight cars was flying over the United States, and it was shot down and everything changed when it came to talking to each other,” he said. “I think you’ll see it start to thaw very soon.

If there is a turnaround, it may be due to the hushed talks Sullivan held in Vienna this month with Wang Yi, China’s top foreign policy official.

The sessions were hardly warm, but in some ways they were more frank and helpful than US officials had expected. Instead of simply reciting talking points, as is typical of meetings with Chinese counterparts, Wang spoke in more unwritten terms than usual, according to officials familiar with the talks. There were complaints on both sides that the Biden team hoped would help clear the air.

There were long talks above all about Ukraine and Taiwan. Wang stressed that China was not seeking conflict with Taiwan, but was apparently trying to reassure US officials who feared last summer that China might accelerate its plans to resolve its dispute over Taiwan by force.

Wang addressed the need to avoid hasty actions surrounding Taiwan’s elections early next year. Mr Sullivan stressed that China’s own behavior raised the temperature and increased the risk of escalation.

Administration officials hope to return to a more regular dialogue with China, perhaps sending Treasury Secretary Janet L. Yellen and Commerce Secretary Gina Raimondo to China, and eventually rescheduling a trip to Beijing by Secretary of State Antony J. Blinken, who canceled a visit after the spy balloon episode . There is talk of a meeting between Mr. Biden and Mr. Xi during the fall.

But the war in Ukraine will continue to overshadow the relationship – and so will the relationship between Moscow and Beijing, which one of Mr. Biden’s aides call it “the alliance of the afflicted.” Still, for now, U.S. officials have taken comfort in the fact that, as far as they know, China has not provided lethal weapons to Russia despite President Vladimir V. Putin’s need for armor.

David Pierson contributed reporting.