Leading political figures, including three former presidents - Barack Obama, George Bush and Bill Clinton - came together to pay tribute to the late senator from Arizona.
But the current US leader, who was not invited to the memorial at the Washington National Cathedral, decided to head to a Virginia golf course.
There, he tweeted about the dispute about the North American Free Trade Agreement (NAFTA) with the Canadian government.
“There is no political necessity to keep Canada in the new NAFTA deal," he wrote. "If we don’t make a fair deal for the US after decades of abuse, Canada will be out. Congress should not interfere w/ these negotiations or I will simply terminate NAFTA entirely & we will be far better off...”
Shortly afterwards, he followed up with: “Remember, NAFTA was one of the WORST Trade Deals ever made. The US lost thousands of businesses and millions of jobs.”
Some Twitter users quickly urged Mr Trump to "show some respect,” asking him to stay off the platform while Mr McCain’s funeral took place at the US Naval Academy in Annapolis, Maryland.
Among those paying tribute were the former presidents George W Bush and Barack Obama, along with his children and wife Cindy McCain.
Mr Trump did not mention the senator's funeral.
Shortly after his tweets, Robert Reich, a professor at the University of California, Berkley and well known political commentator, tweeted: “Only a true egomaniac would throw a tantrum to distract from a funeral.”
US rapper Twista wrote: “Respect the dead, hold your tweets till after the funeral.”
Author and editor Christopher Dickey said Mr Trump’s tweets “keep interrupting the feeds from the McCain funeral, which is so much more important to the future of the United States than your imagined prowess as a deal maker.”
Immigration lawyer Mana Yegani added: “He doesn’t know what to do but send out irrelevant tweets. Trump getting completely ignored on this day of Remembrance.”
The US president reportedly arrived at the golf course just as the funeral was getting underway.
He had earlier tweeted about the Russia investigation, attacking the FBI, Justice Department and the infamous dossier compiled by former British spy Christopher Steele.
Join our commenting forum
Join thought-provoking conversations, follow other Independent readers and see their replies