Mr Trump called for unity in the wake of the attacks in Texas and Ohio and spent Wednesday visiting emergency responders and survivors.
But criticism over his rhetoric and lack of action on gun control did not go away.
In El Paso, Texas, some protesters carried signs saying “racist, go home”.
There were similar scenes in the other city he visited, Dayton, in Ohio. Supporters of President Trump also took to the streets.
In total 31 people died in the attacks in El Paso and Dayton, which took place within hours of each other.
What was the mood in El Paso?
Mr Trump and his wife Melania were met at the airport by Texas Governor Greg Abbott and El Paso Mayor Dee Margo before being driven away.
They spent more than an hour at the city’s University Medical Center talking with staff and victims before travelling to the emergency operations centre.
Some protesters along the route held placards reading “Go home. You are NOT welcome here!” and “Trump hatred, racism not welcome here”.
The Democrat congresswoman who represents El Paso, Veronica Escobar, refused to meet him, saying his “racist and hateful words & actions” had caused pain to her community and her country.
She and Democratic presidential hopeful Beto O’Rourke, an El Paso native, attended a rally where Mr O’Rourke said the president was “vilifying” immigrants.
Mr Trump has mocked Mr O’Rourke’s “phony nickname” and told him to “be quiet” before the trip.
The El Paso shooting, which left 22 people dead, is being treated as a possible hate crime. Much of the city identifies as Hispanic and the suspect is thought to be the author of a text posted online which said “this attack is a response to the Hispanic invasion of Texas”.
The text echoed some of the US president’s language, with Mr Trump having frequently used the term “invasion” to describe the situation on the US-Mexico border.
How was the reception in Dayton?
After the presidential couple were met at a local air base by Dayton Mayor Nan Whaley, they went on to Dayton’s Miami Valley Hospital to meet survivors, emergency workers and staff.
“You had God watching,” the president told survivors and families. “I want you to know we’re with you all the way.”
Outside the hospital, protesters flew a “baby Trump” balloon and held signs reading “Do Something”, “Save our city” and “You are why”.
Both Mayor Whaley and Ohio’s Democratic Senator Sherrod Brown said it was right for the US president to visit and that he had been well received by victims.
But they expressed concern over his past rhetoric and said they had pressed him on gun control. Mr Brown accused Mr Trump of being “in bed” with the National Rifle Association.
Their news conference sparked a strong response from the US president on Twitter, who called it a “fraud”.
“It bore no resemblance to what took place with those incredible people that I was so lucky to meet and spend time with. They were all amazing!” he wrote.
Nine people died in the Dayton shooting. The gunman, 24-year-old Connor Betts, was shot dead by police within 30 seconds of him opening fire. His sister was among the victims.
Police have still to establish a conclusive motive for the Dayton attack but say they have uncovered evidence “that the shooter was exploring violent ideologies”.
Trump the consoler?
In the face of tragedy, the American public has come to expect US presidents to serve as “consoler in chief” – soothing the nation’s frayed nerves and giving voice to its grief.
This is a relatively new role for the American chief executive, made possible in part by the ease of modern travel and the spread of mass media. It is also a role with which the current president has sometimes struggled.
By now the pattern is familiar. After a mass shooting or other tragedy, Mr Trump gives a televised speech, complete with references to religious scripture, expressions of sympathy for the affected and praise for first responders.
Then, in the following days, the off-the-cuff president – the one who loves firing off tweets, riffing to crowds at campaign rallies and giving impromptu press conferences – undermines his scripted rhetoric.
After Charlottesville, the president described some among the crowd of the torch-bearing white supremacists as “very fine people”. During a photo op in hurricane-ravaged Puerto Rico, Mr Trump glibly tossed paper towels to people at an aid station and feuded with the territory’s public officials.
Mr Trump has notable political abilities – ones that have allowed him to rocket to the highest office in the US. He has yet to demonstrate, however, that public displays of empathy are a reliable part of his skill set.
How else has Trump responded?
In a speech on Monday, he said: “In one voice, our nation must condemn racism, bigotry and white supremacy. These sinister ideologies must be defeated. Hate has no place in America.”
As well as advocating mental health gun control reforms, he called for the death penalty for those who committed mass murder and more bi-partisan co-operation over gun laws.
White House spokesman Hogan Gidley said it was “ridiculous” to blame Mr Trump for the El Paso shooting, adding, “You have to blame the people here who pulled the trigger.”
Attempts by Mr Trump and others to link the shootings to mental illness have been criticised by healthcare professionals.
“It is important to note that the overwhelming majority of people with mental illness are not violent and far more likely to be victims of violent crime than perpetrators of violence,” the American Psychiatric Association warned against stigmatising mentally ill people.