The killing of five Dallas police officers in a sniper attack Thursday, which appeared to be racially motivated, is adding uncertainty to the presidential race between Hillary Clinton and Donald Trump. 

The mayhem in Dallas in which seven officers were also wounded closely followed two high-profile killings of black men by police.

The violence has sparked a nationwide mix of anger and sorrow, as well as fear of what is to come, forcing Clinton, Trump and their surrogates to grapple with finding the right tone in what has been a markedly negative campaign.

In a telling sequence of events reflecting the tragedies of the past two days, Clinton and her aides twice rewrote a speech she was intended to give on Friday, where Vice President Biden was initially expected to appear for his first campaign event with the likely Democratic nominee in his hometown of Scranton, Pa.

Clinton’s speech was first retooled so that she could address the police killings of Alton Sterling and Philando Castile, according to a campaign aide. The speech was then redrafted again after the events in Dallas.

On Friday, the Scranton speech and the event with Biden were scrapped, but Clinton did speak at a historically African-American church in Philadelphia Friday evening, where she pledged to pursue criminal justice reform and called for unity. It's an appropriate setting, her allies say, to discuss the current tensions the nation faces. 

Trump canceled a Miami event, which doubled as a tryout opportunity for potential running mate Chris Christie, the New Jersey governor. 

The likely GOP nominee also released a statement that was notable because it decried both the violence in Dallas and the killings of Sterling and Castile.

It called the Dallas shootings a “coordinated, premeditated assault on the men and women who keep us safe.” And he said the “senseless, tragic deaths” of Sterling and Castile “reminds us how much more needs to be done.”

At the same time, an error in Trump’s statement suggested it was done hurriedly. He referred to the two slain black men as motorists, though only one was in a car at the time of the shooting.

Trump’s tone came as a surprise to many, given that he blamed last month’s Orlando nightclub shooting on President Obama and called for his resignation. It was a damaging political misstep for the GOP standard bearer; polls showed a majority of Americans disapproved of his response to the Orlando attack. 

This time he followed the traditional political playbook, so much so that his rhetoric about this week’s violence mirrored Obama’s and Clinton’s. 

It suggested both campaigns will suspend their political attacks as the nation mourns the fallen police officers.

“In the immediate aftermath you want to be as calm and thoughtful as can be,” said Republican strategist Matt Mackowiak, who also writes for The Hill's Contributors blog. “There’s not a lot of upside of doing otherwise. There are only downsides.”

While both candidates have so far tread carefully, they’ll be forced to confront divisive topics such as gun laws, racial bias in law enforcement and the Black Lives Matter movement in the coming days and weeks.

“You cringe at considering the political ramifications of tragedy, but moments like this do have a focusing effect for voters,” said Democratic strategist David Wade, a former chief of staff to Secretary of State John Kerry. 

Trump’s temperament and judgment will once again enter the spotlight, as he’s certain to face questions about whether he’s equipped to deal with national tragedies as president. 

“These tend to be presidential moments where character counts and unserious candidates fall apart,” said Wade. “[Voters] will be looking for a steady leader, and Clinton occupies that space. Trump's the kind of candidate who reflects the red hot irrational anger that sometimes boils over in tragedy, Clinton's the president who can help heal after tragedy. It's a big difference.”

But Clinton could also struggle with a divided electorate that’s upset with the seemingly endless string of violence that has plagued Obama’s presidency. 

“Trump has benefitted from the enormous anxiety people are feeling,” said Mackowiak. “Hillary is a status quo candidate running for Obama’s third term, she’s not calling for any kind of major change. She’s working along the margins.”

The debate over how to address gun violence again reared its head in the hours following the Dallas shooting. 

Obama’s initial response, made in the early morning hours in Warsaw, Poland, generally earned bipartisan praise. But some Republicans took objection to his assertion that the nation’s gun laws may have contributed to the killings. 

“We also know when people are armed with powerful weapons. Unfortunately, it makes attacks like these more deadly and more tragic,” the president said. “In the days ahead, we will have to consider those realities as well.”

Former presidential candidate and Trump surrogate Ben Carson blasted those comments during a Friday morning interview on Fox News. 

“I guess the real issue is, you know, the president’s gonna start saying, ‘See? Gun control,’ ” he said. 

While some Republicans argue that fault lines over race and guns will persist under Clinton’s watch, some Democrats don’t see that being a problem for her campaign. 

“On issues of race, in some ways she’ll have it easier and she’ll be able to say things without the immediate assumption” Obama faced as a black president, said Democratic strategist Jamal Simmons.

While many voters have been drawn to Trump’s bumper-sticker slogan of “Make America Great Again” particularly in times of turmoil, Simmons said that the presumptive Republican nominee’s intention is to “bring people back to the Ozzie and Harriet era,” implying that could further turn off young people and nonwhite voters.