An ambush on Police officers at a protest in Dallas that left five officers dead on Thursday night altered the contours of a presidential campaign, with Hillary Clinton and Donald Trump canceling political events on Friday, and striking different tones about the events in Texas, which Mr. Trump called “an attack on our country” and Mrs. Clinton used as evidence of the need for “more love and kindness.”
“It is a coordinated, premeditated, assault on the men and women who keep us safe,” Mr. Trump said in a statement. “We must restore law and order.”
In what seemed a more restrained reaction from a presumptive Republican nominee known for his charged Twitter rants, Mr. Trump also made his first statement about two black men killed by white police officers earlier this week.
“The senseless tragic deaths of two motorists in Louisiana and Minnesota reminds us how much needs to be done,” he said. “Racial tensions have gotten worse, not better.”
The Louisiana victim, Alton Sterling, was not a motorist, and Mr. Trump later corrected his statement on Facebook to reflect that.
In an interview with CNN, Mrs. Clinton praised the slain Dallas officers and called the attack “an absolutely horrific event.” She promptly brought the conversation back to the shootings of Mr. Castile and Mr. Sterling, which were recorded in graphic videos that lit up social media and reignited outrage and debate over the treatment of black men by white police officers.
“We’ve got to do everything possible to support our police and to support innocent Americans who have encounters with police,” Mrs. Clinton said. She vowed to fight “systemic racism” in police departments and to better train and integrate law enforcement officials into the communities they serve.
She also called on white Americans to empathize with African Americans who live in fear of clashes with the police. “We’re the ones who have to start listening to the legitimate cries that are coming from our African American fellow citizens,” Mrs. Clinton said.
On Friday morning, Mrs. Clinton offered condolences to the families of the police officers killed in Dallas.
“I mourn for the officers shot while doing their sacred duty to protect peaceful protesters, for their families and all who serve with them,” Mrs. Clinton wrote on Twitter on Friday.
She postponed a rally with Vice President Joseph R. Biden Jr. in Scranton, Pa., that had been scheduled for Friday, but planned to address the shootings of Mr. Sterling in Baton Rouge, La., and Philando Castile in Falcon Heights, Minn., and the Dallas attacks, at the African Methodist Episcopal Church conference early Friday evening in Philadelphia.
Mr. Trump, who was also invited to address the A.M.E. conference, a gathering of influential black clergy, didn’t initially respond to the shootings.
But the attack in Dallas, which occurred during protests of the shootings of black men by white police officers and was carried out by a gunman who said he wanted to shoot white police officers, added urgency for both candidates and their parties to address racial fissures, while showing support for law enforcement officials.
On Friday morning, Mr. Trump asked the New York Police Department if he could address an afternoon roll call at a Midtown Manhattan police precinct to solidarity with the police, but the N.Y.P.D. denied his request.
“Our interest is in staying out of the politics of the moment, not to provide photo-ops,” the police commissioner, William J. Bratton, said during a news conference at Police Headquarters in Manhattan.
The events in Dallas came weeks after the attack on a gay nightclub in Orlando, Fla., which forced both Mrs. Clinton and Mr. Trump to scramble to address bigotry, homegrown terrorism and gun violence.
Mrs. Clinton had made criminal justice reform and improving relations between police forces and black communities central to her Democratic primary campaign, calling for an end to the “era of mass incarceration,” and she often campaigned alongside the mothers of black men killed in clashes with the police.
Appearing alongside Mr. Biden would have complicated that message.
The vice president enjoys a close bond with police officers, but he also played a central role in enacting the 1994 Violent Crime Control and Law Enforcement Act. That legislation, signed into law by Bill Clinton, put more police officers on the streets, built dozens of new prisons and created tougher penalties for drug offenders, and has been widely criticized as having an adverse impact on black communities and the high levels of incarceration, arrest, and police presence that have contributed to the current tensions.
Mrs. Clinton has not put as much emphasis on the issue of criminal justice in the general election campaign. That is expected to change in light of the deaths of Mr. Castile and Mr. Sterling and the killings of the police officers in Dallas.
If Mr. Trump sought to project a modicum of measured reaction to the shootings, his campaign’s state chairman in Virginia, Corey Stewart, went sharply in a different direction.
Mr. Stewart, who is also reported to be planning a run for governor in Virginia in 2017, posted on Facebook as news of the shooting was breaking, explicitly blaming Mrs. Clinton for the deaths.
“Liberal politicians who label police as racists — specifically Hillary Clinton and Virginia Lt. Governor Ralph Northam — are to blame for essentially encouraging the murder of these police officers tonight,” Mr. Stewart wrote, sharing a link to the ABC News report on the shootings in a post that he later deleted.
Hope Hicks, a spokeswoman for the Trump campaign, said that “Corey does not speak for the campaign and this is not something we agree with.”