BRUSSELS — NATO leaders on Monday agreed to pivot their alliance to a more confrontational stance toward China, a landmark shift as President Biden sought to boost and reorient the organization after the eruptions and conflict that marked the Trump era.

Biden, in public comments and private meetings at the midway point of his first overseas trip as president, worked to reassure dubious allies that America is back and to rally like-minded democracies in what he repeatedly cast as an existential battle against the world’s autocracies.

Monday’s discussion was a sharp expansion of NATO’s efforts to confront Beijing after years when China was outside the focus of the defensive alliance. The allies agreed in their closing communique that “China’s stated ambitions and assertive behavior present systemic challenges to the rules-based international order.”

“I think that there is a growing recognition over the last couple of years that we have new challenges,” Biden said during a sit-down discussion with NATO Secretary General Jens Stoltenberg. “And we have Russia that is not acting in a way that is consistent with what we had hoped, and as well as China,” Biden said. He added that members of the Group of Seven had “stepped up as well,” an apparent reference to a new willingness among the economic club to criticize some aspects of Chinese behavior.

After the meeting, Stoltenberg said it was an achievement for the alliance to start pivoting toward China. “It’s not about moving NATO to Asia,” he said. But, he added, “we need to address the challenges that the rise of China poses to our security even though many allies have a lot of economic ties with China.”

The notion of shifting NATO’s attention at least somewhat to China extends the theme of Biden’s European trip, after he also tried to sharpen China-related discussions at the Group of Seven summit in Britain. Biden has repeatedly cast the struggle of the current generation as one between democracies and autocracies such as China and Russia, and he reiterated that concern at a news conference Monday in Britain before departing for Brussels.

“We’re in a contest — not with China per se — but a contest with autocrats, autocratic governments around the world, as to whether or not democracies can compete with them in the rapidly changing 21st century,” Biden said.

Although the NATO leaders signed off on the sharper language on China, disagreements remained about the best role for a group that has traditionally focused on Russia and direct threats to NATO members, such as terrorism.

Just a few years ago, talk about Beijing at NATO was nearly nonexistent. Even to raise the issue in NATO hallways was taboo, with some members wary that doing so would push relations with the country into a Cold War-era framework of superpower rivalry.

But China has become more aggressive on the world stage, and Washington has become more hawkish toward Beijing. President Donald Trump pushed the organization to be more confrontational. Biden has continued the effort and even accelerated it.

For the alliance’s battered leaders, it was already victory enough that they were meeting with a U.S. president who was not threatening to pull out of NATO on the spot. And at a closed-door meeting that marked the first NATO summit since Trump left office, leaders mostly set aside divisions to embrace one another after four turbulent years.

Almost all the leaders declared delight that the United States “was back,” according to two officials who listened to the discussions, a possible sign that Biden’s trip may be succeeding in reassuring shaky European allies — or at least that expectations were low.

The meeting “was like the first day back at school, seeing all your old friends again,” British Prime Minister Boris Johnson told fellow leaders, according to Stoltenberg.

“And that was really the atmosphere in the room,” Stoltenberg told reporters after the meeting.

Biden, at a news conference, was asked how he can reassure European leaders that the United States can keep its promises from administration to administration, given the deadly insurrection aimed at overturning his election and the political power Trump still holds.

“What I’m saying to them is, ‘Watch me,’ ” Biden said. He then quoted an old idiom, “The proof of the pudding is in the eating.”

Biden described the four years of Trump as a “disappointing” aberration, arguing that NATO and Group of Seven leaders know that the United States is “a decent, honorable nation” and that “the American people aren’t going to sustain that kind of behavior.”

The president skirted close to an unofficial taboo of overseas travel — talking about domestic politics — as he acknowledged Trump’s outsize hold on the GOP but downplayed his predecessor’s overall influence.

“I think it’s appropriate to say that the Republican Party is vastly diminished in numbers, the leadership of the Republican Party is fractured, and the Trump wing of the party is the bulk of the party, but it makes up a significant minority of the American people,” Biden said.

Asked whether allies were queasy about his Wednesday sit-down with Russian President Vladimir Putin, Biden said that each ally who raised the meeting at all had “thanked me for meeting with Putin now.”

The president used his news conference to send a fresh warning to Putin just two days before their meeting in Geneva.

“I’m going to make clear to President Putin that there are areas where we can cooperate if he chooses,” Biden said. “And if he chooses not to cooperate and acts in a way — in a way that he has in the past relative to cybersecurity and some other activities — then we will respond. We will respond in kind.”

Biden’s approach, like that of presidents before Trump, is to attempt to find common ground with Russia when “it’s in our mutual interest, in the interest of the world to cooperate,” he said.

And, he added, on “the areas that we don’t agree, make it clear what the red lines are.”

Biden knows Putin better than any recent president has. But when pressed, he declined to repeat verbatim an earlier assertion that Putin is “a killer.”

“I had met with him. He’s bright, he’s tough, and I’ve found that he is a — as they say when I used to play ball — a worthy adversary,” Biden said.

In forcefully pushing back against the Kremlin and Beijing, Biden suggested that the United States and its allies could offer a more appealing alternative to autocratic regimes.

“I pointed out we have to prove to the world and to our own people that democracy can still prevail against the challenges of our time,” Biden said. “This is going to be looked at 25 years from now as whether or not we stepped up to the challenge.”

Not every NATO country, however, is completely on board with confronting China more forcefully. Some, such as Hungary, have friendly relations with China and seek investments from Beijing. Others such as Germany and other big European powers fall in the middle, believing there is a balance between the need to work with Beijing to fight climate change and the need to rein in its global ambitions. Others worry that too much focus on China could distract from the alliance’s traditional central mission of defending against Russia.

The sharpest discussions inside the meeting were with French President Emmanuel Macron, who in 2019 declared the “brain death” of NATO under Trump. Macron took a tough line against increasing funding for NATO’s central operations, which are a rounding error compared with the alliance’s overall defense spending. Other countries had hoped this could be a symbolic way to move beyond the divisions of the Trump era. They eventually agreed to increase the budget — but to put off a decision on the final figures until later.

Afterward, Macron shrugged off the fight, saying that leaders had acknowledged his push for Europe’s “strategic autonomy” and that in the end, “that’s enough for me.”

In a statement Monday as the summit wound down, Trump criticized the alliance, arguing that the United States was getting a bad deal.

“So much USA money has been given away to the ‘Club,’ as President Macron of France likes to call it, and to NATO, despite the fact that those countries have taken economic advantage of the United States for many years — until I came along,” Trump wrote. “Not fair to America, or the American taxpayer!”

But the overarching feeling of unity was even joined by Turkish President Recep Tayyip Erdogan ahead of his first meeting with the new U.S. president, which was set to be Biden’s first tough discussion of this international tour. Erdogan, who can be combative at NATO summits, was mild-mannered Monday, opting for a friendlier approach, according to the officials who listened to the discussion, who spoke on the condition of anonymity to talk frankly about what happened behind closed doors.

The two leaders met for well over an hour, in a smaller setting and then a larger one. The Turkish government released photos of them bumping elbows, apparently in good humor, and when reporters were briefly ushered into the room at the end of their discussion, Biden called it “a very good meeting.”

During the presidential campaign, Biden called Erdogan an “autocrat,” and Ankara has been disruptive at NATO and elsewhere. The meeting could serve as a preview of sorts for Biden’s session with Putin.

Meanwhile, NATO leaders agreed that their treaty’s Article 5 provision — which states that an attack on one allied nation is an attack on all — could be applied to cyber and ransomware attacks.

“The notion is that if someone gets hit by a massive cyberattack, and they need technical or intelligence support from another ally to be able to deal with it, they could invoke Article 5 to be able to get that,” Jake Sullivan, Biden’s national security adviser, told reporters Sunday ahead of the meeting.

It is a growing challenge for the Biden administration, which has threatened to retaliate after attacks from cybercriminal collectives in Russia but has so far announced no concrete consequences. In May, one such attack on a major U.S. oil pipeline disrupted fuel supplies in parts of the country, and another attack at the end of the month temporarily forced the world’s largest meat producer to shut down all of its U.S. beef plants.

NATO leaders also discussed the pullout from Afghanistan, mostly falling in line behind Biden’s decision to withdraw troops despite some reservations that there was little consultation in advance.

“I believe — and I’ve said this my whole career and the four years I was out, when I decided to run for president again — that NATO is — Article 5, we take as a sacred obligation,” Biden said as he sat with Stoltenberg on Monday, a memorial to the 9/11 attacks behind them.

“And I just want all of Europe to know that the United States is there,” Biden said. “The United States is there.”

Quentin Ariès contributed to this report.