Also on Thursday, a moderate Republican Senator Lisa Murkowski broke ranks to say she was unsure if she would support Mr Trump's bid for re-election.
Protesters have filled the streets across the United States after an unarmed black man, Mr Floyd, died in the custody of four white police officers in Minneapolis in May.
"Never did I dream that troops taking that same oath would be ordered under any circumstance to violate the constitutional rights of their fellow citizens - much less to provide a freaky photo op for the elected commander-in-chief, with military leadership standing alongside", a reference to Trump posing outside historic St. John's Church on Monday after walking through an area cleared of protesters.
Mattis had always been reluctant to publicly criticise Trump but broke his silence this week after Trump called for the military to "dominate the streets" and had peaceful protesters cleared from the White House perimeter with tear gas so he could have a photo-op at St. John's Church.
"I thought General Mattis' words were true and honest and necessary and overdue", Ms Murkowski told reporters at the US Capitol.
"I remember that the military was mobilized but received criticism for whether there was excessive use of force and there was grave concern at the time that this would not be a good core mission for the military going forward".
"Few people know where they'll be in two years from now, but I do, in the Great State of Alaska (which I love) campaigning against Senator Lisa Murkowski", the president said.
"There is a concern, I think an bad big concern, that the partisanship has gotten out of hand, the tribal thing has gotten out of hand", Mr. "If you have a pulse, I'm with you!" the President tweeted.
Trump's former Trump defence secretary, General James Mattis, chimed in with a strongly worded statement criticising Trump directly for his divisive rhetoric during the protests.
Lorde pens fan letter after attending Auckland Black Lives Matter protest
Justice Horn was one of the organizers of Sunday's Black Lives Matter protest, which included several speakers from 2 to 4 p.m. We are all equal and it doesn't matter our origin, the colour of our skin, our religion, our sexuality, we are all human.
Later that night, Esper and Milley, joined by Army Chief of Staff Gen. James McConville and Army Secretary Ryan McCarthy, visited National Guard troops in D.C.
Trump finally relented on Thursday, an administration official who asked not to be named told the news outlet, but it did not appear that the president spoke with Esper directly.
Defense Secretary Mark Esper and Joint Chiefs of Staff Chairman Gen. Mark Milley are refusing to testify to the House Armed Services Committee on how the military has responded to police brutality protests around the country, a House aide told the Hill.
Writing in The Atlantic, the former Defense Secretary had said Mr. Trump was trying to divide the country which had not, for years, had " mature leadership".
Mattis, a retired Marine Corps general, largely has kept a low public profile since resigning in 2018 to protest the president's impulsive decision to withdraw troops from Syria.
"I am deeply anxious that as they execute their orders, the members of our military will be co-opted for political purposes", wrote Mr Dempsey's predecessor, retired admiral Mike Mullen. It also adds fuel to questions about the proper civil-military relationship and how the American military can and should be deployed on domestic soil.
But tensions between the Pentagon and Trump are only expected to escalate as more former top commanders come forward to express their opposition to the president's moves.
And it effectively shattered Mr Trump's claim to a solid alliance with the men and women in uniform, which he parades in political ads as a sign of his own toughness.