Donald Trump and Hillary Clinton responded Friday to the killings of five police officers in Dallas, as well as the recent deaths of two black men in police shootings, with restrained remarks and by canceling most campaign events.

Both presidential candidates scrapped political events hours after the officers were gunned down by a former Army reservist during a protest over fatal police shootings of black men in Louisiana and Minnesota.

Alton Sterling was shot Tuesday after struggling with two white officers who eventually pinned him to the pavement. On Wednesday, Philando Castile was fatally shot in a car by a Minnesota officer, with the aftermath livestreamed on Facebook by his girlfriend.

Hundreds of people gathered in Dallas to protest the killings Thursday night when Micah Xavier Johnson opened fire, killing five police officers and injuring seven others.

Clinton went ahead with an evening appearance Friday at the African Methodist Episcopal Convention in Philadelphia, in which she issued renewed calls for criminal justice reform and gun control as well as expressing support for police officers.

“We cannot, must not vilify police officers. Remember what those officers were doing when they died.  They were protecting a peaceful march,” Clinton said.

However, she also called for Americans to work to end "systemic racism" and rebuild communities.

“White Americans need to do a better job of listening when African Americans talk about the seen and unseen barriers you face every day. We need to try, as best we can, to walk in one another’s shoes,” she said.

Trump, meanwhile, canceled a speech in Miami on Hispanic issues. He instead released a lengthy statement calling the shootings in Dallas "a coordinated, premeditated assault on the men and women who keep us safe."

“We must restore law and order. We must restore the confidence of our people to be safe and secure in their homes and on the street,” Trump said. “The senseless, tragic deaths of two people in Louisiana and Minnesota reminds us how much more needs to be done.”

“This morning I offer my thoughts and prayers for all of the victims’ families, and we pray for our brave police officers and first responders who risk their lives to protect us every single day,” he said.

In a video statement late Friday, Trump also called for unity among Americans.

“Now is the time for prayers, love, unity and leadership. Our children deserve a better future than what we are making them live through today, but to get them there we must work together and stand together,” Trump said.

The Associated Press contributed to this report.