THE HAGUE, Netherlands >> NATO leaders agreed on a massive hike in defense spending Wednesday after pressure from U.S. President Donald Trump, and expressed their “ironclad commitment” to come to each other’s aid if attacked.

The 32 leaders endorsed a final summit statement saying: “Allies commit to invest 5% of GDP annually on core defense requirements as well as defense- and security-related spending by 2035 to ensure our individual and collective obligations.”

The show of unity vindicated NATO Secretary-General Mark Rutte’s billing of the summit as “transformational,” even though it papered over divisions.

Trump called the spending boost “something that no one really thought possible. And they said, ‘You did it, sir. You did it.’ Well, I don’t know if I did it, but I think I did.”

Spain had already officially announced that it cannot meet the target, and others have voiced reservations, but the investment pledge includes a review of spending in 2029 — after the next U.S. presidential elections — to monitor progress and reassess the security threat posed by Russia.

The leaders also underlined their “ironclad commitment” to NATO’s collective security guarantee — “that an attack on one is an attack on all.” Ahead of the summit, Trump had again raised doubts over whether the United States would defend its allies.

“Together, allies have laid the foundations for a stronger, fairer and more lethal NATO,” Rutte told reporters after chairing the meeting in The Hague. “This will fuel a quantum leap in our collective defense.”

The spending hike requires each countries to spend billions of dollars. It comes as the United States — NATO’s biggest-spending member — shifts its attention away from Europe to focus on security priorities elsewhere, notably in the Middle East and Indo-Pacific.

Spain had called the new spending target and 2035 deadline “unreasonable.” Belgium signaled that it would not get there either, and Slovakia said it reserves the right to decide its own defense spending.

Prime Minister Pedro Sánchez stood conspicuously aside from other leaders in the summit family photo. After the meeting, he said that Spain can execute NATO’s defense plans by spending only 2% of gross domestic product on defense.

“In today’s summit, NATO wins and Spain wins something very important for our society, which is security and the welfare state,” Sánchez said.

Trump lashed out at Spain after the meeting.

“They want to stay at 2%. I think it’s terrible,” he said. “You know, what we’re going to do? We’re negotiating with Spain on a trade deal. We’re going to make them pay twice as much.”

Along with Spain, many other European countries face major economic challenges, and Trump’s global tariff war could make it even harder for America’s allies to reach their targets. Some countries are already squeezing welfare and foreign aid spending to channel extra funds into their military budgets.

On Tuesday, Trump complained that “there’s a problem with Spain. Spain is not agreeing, which is very unfair to the rest of them, frankly.” He has also criticized Canada as “a low payer.” In 2018, a NATO summit during Trump’s first term unraveled due to a dispute over defense spending.

Other countries closer to the borders of Russia and Ukraine — Poland, the three Baltic states and Nordic countries — have committed to the 5% goal, as have NATO’s European heavyweights Britain, France, Germany and the Netherlands.

In their statement, the leaders said they were united “in the face of profound security threats and challenges, in particular the long-term threat posed by Russia.” It had been feared that Trump would object to that assessment, which European governments need to justify higher spending.

Trump has been reluctant to support Ukraine in its war against Russia’s full-scale invasion.

“We stand by Ukraine in its pursuit of peace and will continue to support Ukraine on its irreversible path to NATO membership,” Rutte said. The Trump administration has vetoed Ukraine’s bid to join NATO for the foreseeable future.

Finnish President Alexander Stubb said the agreement “is a big win, I think, for both President Trump and I think it’s also a big win for Europe.” He told reporters that “we’re witnessing the birth of a new NATO, which means a more balanced NATO.”