Former Trump administration defence secretary Jim Mattis has accused the president of trying to "divide" the US and of failing to provide "mature leadership" as the country reels from days of protests.

Mr Mattis, who resigned in December 2018 over Mr Trump's ordering of a full troop withdrawal from Syria, also voiced support for the demonstrators whose anti-racism rallies have roiled the country.

"Donald Trump is the first president in my lifetime who does not try to unite the American people - does not even pretend to try," Mr Mattis wrote in a statement posted online by The Atlantic.

"Instead, he tries to divide us," continues the retired Marine general, who had previously said it would be inappropriate for him to criticise a sitting president.

He describes Mr Trump as "a threat to the constitution" and drew a comparison to the war against Nazi Germany, saying "US troops were reminded before the Normandy invasion: 'The Nazi slogan for destroying us was 'Divide and Conquer'."

Four US police officers charged over George Floyd death
Pope and UN human rights head condemn racism and violence in US
Violence spreads in US as Trump faces anger for ordering force
Twitter flags Trump tweet for 'glorifying violence'

Mr Mattis also took a swipe at current US military leadership and criticised use of the word "battlespace" by Defense Secretary Mark Esper and Army General Mark Milley, chairman of the Joint Chiefs of Staff, to describe protest sites in the US.

"We must reject any thinking of our cities as a 'battlespace,'" Mr Mattis wrote.

Mr Trump's threats to deploy active duty troops - even in states that oppose their use - has stirred alarm within the US military and in Congress, where a top Republican warned it could make troops "political pawns".

"We are witnessing the consequences of three years without mature leadership," Mr Mattis stated.

The former Pentagon chief described himself as "angry and appalled" after witnessing events of the last week, which saw Mr Trump threaten a military crackdown as nationwide protests turned violent in some cities.

New York: Security forces take measures on the ninth consecutive day of protests

The fury was ignited by the 25 May killing of African American man George Floyd, who suffocated beneath the knee of a white police officer.

Footage of the moment filmed by bystanders swiftly went viral.

The demonstrations have mostly been peaceful, but some have degenerated into violence and looting.

Mr Mattis wrote that the protesters' call for equal justice was a "wholesome and unifying demand - one that all of us should be able to get behind".

And he criticised the decision to use force to clear peaceful protesters from near the White House on Monday to allow Mr Trump to pose for photographs at a nearby church.

The photo-op has become a lightning rod for criticism of Mr Trump's handling of the crisis, with religious leaders, politicians, and onlookers around the country expressing outrage.

"When I joined the military, some 50 years ago, I swore an oath to support and defend the Constitution," Mr Mattis states.

"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 bizarre photo-op for the elected commander-in-chief, with military leadership standing alongside."

Responding scathingly on Twitter, President Trump described the man he appointed to be US Defense Secretary as the world's most over-rated general, adding he had not liked his leadership style - or much else about him.

Meanwhile, former US president Barack Obama has applauded the "profound" protests by Americans demanding racial justice and said demonstrations over last week's killing of Mr Floyd could spark nationwide reforms.

In his first video comments since Mr Floyd's death he also urged state and local authorities to review their policies on use of force.

Mr Obama directed his comments at young black men and women, who he said have often witnessed or experienced too much violence.

"Too often some of that violence has come from folks who were supposed to be serving and protecting you," Mr Obama said in a webcast with activists.

"I want you to know that you matter. I want you to know that your lives matter, your dreams matter."

He also said that in the last few weeks, Americans have witnessed "the kinds of epic changes and events in our country that are as profound as anything that I've seen in my lifetime".

The 58-year-old, who remains popular among Democrats, noted the deadly upheaval of the 1960s civil rights movement, and said "a far more representative cross-section of America" is protesting now than as compared to half a century ago.

"There is a change in mindset that's taking place, a greater recognition that we can do better," Mr Obama said.

Young protesters in particular have been galvanised, he said, and their motivation could serve as inspiration for broader change.

"It's very important for us to take the momentum that has been created as a society, as a country, and say 'Let's use this' to finally have an impact," Mr Obama said.

He also addressed the country's local leaders, saying "I'm urging every mayor in this country to review your use-of-force policies with members of your community and commit to report on planned reforms."

Mr Obama did not directly address Mr Trump's handling of the unrest, including the president's controversial demand that authorities "dominate" protesters.

A leading African-American congressman said he never thought he would still see scenes of racial unrest in 2020 after being part of the civil rights movement in the 1960s.

House Majority Whip Representative James Clyburn said: "My children and grandchildren seem to be having to live the same things that I lived."

He told RTÉ's States of Mind podcast that "black folks came to this country to be enslaved, so that sets out the foundation on how this country was built.

"What we’ve been trying to do all these years is to restructure that… [but] everything has been structured to maintain white superiority...That's what we’ve been fighting against."

Mr Clyburn, whose endorsement of Joe Biden catapulted him to secure the Democratic nomination for the November presidential election, said US citizens and politicians need to admit the country has a problem with race so it can "survive for the next generation".

He said said it was wrong to believe that electing an African-American president would solve things.

"You can't solve a problem if you don't admit it exists. We've got to admit that there's a structural problem when it comes to race in this country", he said. 

He criticised Mr Trump's response to the demonstrations and accused him of having "no relationship with the truth" and described Mr Trump holding a bible on Monday outside St John’s Episcopal church as a violent act.

"Violence is the unjust use of force or power. And what the president did...was a violent use of power. That's what it was, it was a violent act. Just as violent as someone who would throw a brick through a window."