“President Trump,” the statement said, “wants to see our allies share more of the burden and at a very minimum meet their already stated obligations.”

Still, along with 28 other heads of state, Mr. Trump signed the 23-page NATO declaration, which reflects months of negotiation. That contrasts with Mr. Trump’s departure last month from the Group of 7 summit meeting, when he refused to sign onto the usual carefully crafted communiqué.

[Read the full story here.]

NATO members agreed in 2014 to spend at least 2 percent of gross domestic product on their militaries by 2024. Mr. Trump has repeatedly castigated other countries for spending less, even though the deadline is six years away, but the declaration reaffirmed commitment to that target.

The 79-point joint statement also censured Russia’s actions in Ukraine in the bluntest terms: “We strongly condemn Russia’s illegal and illegitimate annexation of Crimea, which we do not and will not recognize.”

Just over a week ago, the president told reporters on Air Force One that he was considering supporting Russia’s claim to Crimea, which it seized in 2014.

The allies agreed to a NATO Readiness Initiative, which would allow the group to assemble a fighting force of 30 land battalions, 30 aircraft squadrons and 30 warships within 30 days. The initiative reflects a “30-30-30-30” plan pushed by Defense Secretary Jim Mattis and meant to deter Russian aggression in Europe.

As Mr. Trump exited the NATO headquarters, he left allies and analysts alike a bit off balance.

“Trump is coming through and saying, ‘What have you done for me lately?’” Jorge Benitez, a senior fellow at the Atlantic Council, said in an interview. “Trump seems to be defining U.S. national interests that are competitive with our allies and yet cooperative with North Korea, cooperative with Russia, and cooperative with China. That doesn’t seem consistent.” — Katie Rogers