Barack Obama will meet relatives of the five police officers killed in Dallas when a gunman opened fire on a protest march, the White House said.
It released details of the visit the president will make to Dallas on Tuesday, after he was invited by city Mayor Mike Rawlings.
Mr Obama will meet privately with relatives of the police officers, at an event that will also be attended by Vice President Joe Biden, and by George W Bush and his wife Laura. The ex-president will deliver brief remarks.
The White House said Mr Obama plans to "personally express the nation's support and gratitude" for the service and sacrifice of the dead officers.
He also will deliver remarks at an interfaith memorial service at the Morton H Meyerson Symphony Centre.
Seven officers were also injured on Thursday when Micah Johnson attacked the march, which was held to protest against the police killings of two black men in Louisiana and Minnesota last week.
Dallas County Judge Clay Jenkins said the authorities believe Johnson had been intending to carry out an attack for a long time, and learned of the protest and knew there would be a lot of police to protect protesters.
He said Johnson had material for explosives in his home and talked of using IEDs (improvised explosive devices) during a police stand-off that followed the shootings.
Johnson taunted the authorities during two hours of negotiations, laughing at them, singing and at one point asking how many officers he had shot.
The black Army veteran insisted on speaking with a black negotiator and wrote in blood on the wall of a parking garage where police cornered and later killed him, Dallas police chief David Brown said.
Johnson, who was apparently injured in a shoot-out with police, wrote the letters "RB" and other markings. Investigators are now trying to decipher the writing by looking through evidence from his suburban Dallas home.
Mr Brown defended the decision to kill Johnson with a bomb delivered by remote-controlled robot, saying negotiations went nowhere and officers could not approach him without putting themselves in danger.
Mr Brown said he became increasingly concerned that "at a split second, he would charge us and take out many more before we would kill him".
Johnson had practised military-style drills in his garden and trained at a private self-defence school that teaches special tactics, including "shooting on the move".
The Dallas protest was among demonstrations nationwide following the deaths of 32-year-old Philando Castile in St Paul and 37-year-old Alton Sterling in Baton Rouge, Louisiana.
The protests are continuing across the US, and there have been hundreds of arrests, and reports of violence at some of the demonstrations.
Mr Obama earlier called for greater tolerance, respect and understanding from police officers towards the people they take an oath to protect, as well as from individuals who think officers are too heavy handed and intolerant.
During a visit to Spain, which has been cut short due to the growing crisis, the president said: "I'd like all sides to listen to each other."
He said violence against police by anyone concerned about fairness in the criminal justice system does "a disservice to the cause".
He repeated that the vast majority of US police officers are doing a good job, and also called for balance from law enforcement.
"I would hope that police organisations are also respectful of the frustrations that people in these communities feel and not just dismiss these protests and these complaints as political correctness.
"It is in the interest of police officers that their communities trust them."
The president travelled to Spain after attending a Nato summit in Poland, but the shocking series of events in the US last week has dominated most of his public appearances.
He was supposed to spend two days in Spain but cut the visit short because of the shootings.
"We've had a difficult week in the United States," he told King Felipe VI before they met in private at the Royal Palace in Madrid.