The billionaire leader used the highest possible profile platform of his first NATO summit in Brussels to accuse members of the alliance of owing "massive amounts of money".
Unveiling a memorial to the 9/11 attacks at NATO's new headquarters, Trump also urged the alliance to get tougher on tackling terrorism and immigration in the wake of the Manchester attack.
Allies who had hoped to hear Trump publicly declare his commitment to NATO's Article 5 collective defence guarantee were left disappointed as he made no mention of it and instead castigated them on their home turf.
"Twenty-three of the 28 member nations are still not paying what they should be paying and what they're supposed to be paying for their defence," the president said as fellow leaders looked on grim faced.
Trump said that even if they met the commitment they made in 2014 to allocate two percent of GDP to defence, it would still not be enough to meet the challenges NATO faces.
"This is not fair to the people and taxpayers of the United States. Many of these nations owe massive amounts of money from past years," Trump added.
The diatribe stirred memories of his campaign trail comments branding NATO "obsolete" and threatening that states that did not pay their way would not necessarily be defended, which deeply alarmed allies.
NATO chief Jens Stoltenberg was repeatedly asked at a closing news conference about Trump's comments but insisted that while the president might have been "blunt" his message was unchanged -- the allies had to do more.
In dedicating the 9/11 Article 5 memorial, the president was "sending a strong signal" of his commitment to NATO, Stoltenberg said.
"And it is not possible to be committed to NATO without being committed to Article 5."
Julie Bishop attends NATO
Trump said the bombing of a pop concert in the British city of Manchester on Monday, claimed by the Islamic State group, showed that "terrorism must be stopped in its tracks".
"The NATO of the future must include a great focus on terrorism and immigration as well as threats from Russia and NATO's eastern and southern borders," the president said.
The surprising focus on immigration echoed another key feature of Trump's campaign, which included a vow to build a border wall with Mexico, a measure derided in Europe.
German Chancellor Angela Merkel struck an entirely different note as she unveiled a memorial made up of a section of the Berlin Wall to mark the end of the Cold War.
"Germany will not forget the contribution NATO made in order to reunify our country. This is why we will indeed make our contribution to security and solidarity in the common alliance," she said.
Trump's rebuke came despite NATO saying it would formally join the US-led coalition against IS at the summit, despite reservations in France and Germany about getting involved in another conflict.
Article 5 has been invoked only once in NATO's six-decade history -- after the September 11, 2001 attacks on New York and Washington.
Analyst Thomas Wright of the Washington-based Brookings Institution said Trump's failure to publicly declare this was "shocking and damaging".
Brussels presented Trump with the first problems of a landmark foreign trip, including tense moments with the head of the European Union and with key ally Britain.
Trump announced a review of "deeply troubling" US intelligence leaks over the Manchester bombing, in which 22 people died, and warned that those responsible could face prosecution, the White House said.
He later discussed the row with Britain's Prime Minister Theresa May, who had condemned the leaks that left British authorities infuriated with their US counterparts.
Trump meets wary NATO and EU in Brussels
EU Russia tensions
A meeting with European Council chief Donald Tusk and European Commission head Jean-Claude Juncker did not go smoothly either, despite hopes it could clear the bad blood caused by Trump backing Britain's Brexit vote.
During his meeting with the two top EU officials, Trump launched a salvo against Germany and its car sales in the United States, Der Spiegel reported.
"The Germans are bad, very bad," he said, according to the German weekly's online edition.
"See the millions of cars they are selling in the US. Terrible. We will stop this," he reportedly said.
Tusk had earlier said there were differences on climate change and trade but above all Russia.
"I'm not 100 percent sure that we can say today -- 'we' means Mr President and myself -- that we have a common position, common opinion about Russia," said Tusk, a former Polish premier who grew up protesting against Soviet domination of his country.
Trump on the campaign trail made restoring relations with Russia a key promise but he has faced bitter opposition in Washington and has since become embroiled in a scandal over alleged links to Moscow.
Trump also held talks with new French President Emmanuel Macron, with the pair appearing to engage in a brief yet bizarre battle to see who could shake hands the hardest.
Trump came to Brussels direct from a "fantastic" meeting with Pope Francis at the Vatican, after visiting Saudi Arabia, Israel and the Palestinian Territories.