President Biden was eager to get off the stage at the Group of 7 summit Thursday night, clearly a bit testy after answering questions about Hunter Biden’s conviction and the prospects of a cease-fire in Gaza.

But at the end of his news conference with President Volodymyr Zelensky of Ukraine, he couldn’t seem to help jumping in as the Ukrainian leader spoke delicately about China’s tightening relationship with Russia. He leaned into his microphone as soon as Mr. Zelensky was finished.

“By the way, China is not supplying weapons” for the war in Ukraine, Mr. Biden said, “but the ability to produce those weapons and the technology available to do it.”

“So, it is, in fact, helping Russia,” he said.

Throughout the Group of 7 summit meeting in Puglia, China has been the lurking presence: as the savior of “Russia’s war machine,” in the words of the summit’s final communiqué; as an intensifying threat in the South China Sea; and as a wayward economic actor, dumping electric cars in Western markets and threatening to withhold critical minerals needed by high-tech industries.

In total, there are 28 references to China in the final communiqué, almost all of them describing Beijing as a malign force.

The contrast with China’s portrayal just a few years ago is sharp.

At past summits, the West’s biggest economies talked often about teaming with Beijing to fight climate change, counterterrorism and nuclear proliferation. While China was never invited into the G7 the way Russia once was — Moscow joined the group in 1997 and was suspended when it annexed Crimea in 2014 — Beijing was often described as a “partner,” a supplier and, above all, a superb customer of everything from German cars to French couture.