WASHINGTON — President Trump has written sharply worded letters to the leaders of several NATO allies — including Germany, Belgium, Norway and Canada — taking them to task for spending too little on their own defense and warning that the United States is losing patience with what he said was their failure to meet security obligations shared by the alliance.

The letters, sent in June, are the latest sign of acrimony between Mr. Trump and American allies as he heads to a NATO summit meeting next week in Brussels that will be a closely watched test of the president’s commitment to the alliance. Mr. Trump has repeatedly questioned its value and has claimed that its members are taking advantage of the United States.

Mr. Trump’s criticism raised the prospect of another confrontation involving the president and American allies after a blowup by Mr. Trump at the Group of 7 gathering last month in Quebec, and increased concerns that far from projecting solidarity in the face of threats from Russia, the meeting will highlight divisions within the alliance. Such a result could play into the hands of President Vladimir V. Putin of Russia, who is to meet with Mr. Trump in Helsinki, Finland, after the NATO meeting, and whose primary goal is sowing divisions within the alliance.

In his letters, the president hinted that after more than a year of public and private complaints that allies have not done enough to share the burden of collective defense, he may be considering a response, including adjusting the United States’ military presence around the world.