Mr Trump said the US paid “close to the entire cost of Nato” to help protect countries that “rip us off on trade”.
“Fair trade is now to be called fool trade,” he added in response to the threat of new tariffs against the US.
His tirade came after G7 allies criticised his decision to reject a joint communique.
German Chancellor Angela Merkel said on TV late on Sunday that his change of heart was “sobering and a little depressing”. The French presidency had earlier condemned “fits of anger”.
After Mr Trump had left the summit in Quebec he rounded on Justin Trudeau personally, suggesting the Canadian prime minister was “very dishonest and weak” and “acts hurt when called out”.
The summit, which ended on Saturday, was marred by disagreements over trade.
Mr Trudeau described as “insulting” Mr Trump’s decision to invoke national security to justify tariffs. In a news conference after the summit, he vowed to press ahead with retaliatory moves on 1 July.
“Canadians are polite and reasonable but we will also not be pushed around,” he said.
Earlier, differences over the US tariffs on steel and aluminium imports had seemed to have been papered over in a joint communique which advocated a “rules-based trading system”.
Tweeting en route to his next summit in Singapore, Mr Trump said he had instructed US officials “not to endorse the communique as we look at tariffs on automobiles”.
He said the move was based on Mr Trudeau’s “false statements at his news conference, and the fact that Canada is charging massive tariffs to our US farmers, workers and companies”.
Mr Trudeau’s office said the prime minister had said nothing he had not said before, both in public and in conversations with Mr Trump.