WASHINGTON — It was intended to be a day for President Donald Trump to pay his respects to the victims of two deadly mass shootings, thank first responders and serve as consoler-in-chief.

But before he even left the White House on Wednesday for El Paso, Texas, and Dayton, Ohio, the president used his bully pulpit to settle political scores and lash out against slights.

From his private residence Tuesday night, Trump mocked Democratic presidential candidate Beto O’Rourke, an El Paso native, for saying that the president's "racism" was responsible for the mass shooting in Texas.

Then, after telling reporters on the South Lawn of the White House on Wednesday morning that he was trying to stay out of the political fray, he sought to link the Dayton shooter to Democratic presidential candidates Sens. Bernie Sanders of Vermont and Elizabeth Warren of Massachusetts because of a tweet the shooter had posted that mentioned them, though it was unclear whether he supported them.

And while flying on Air Force One between meeting with victims in Dayton and El Paso, he accused Dayton Mayor Nan Whaley and Sen. Sherrod Brown, D-Ohio, of misrepresenting his visit with victims at a Dayton hospital. “Their news conference after I left for El Paso was a fraud,” he tweeted. “It bore no resemblance to what took place with those incredible people that I was so lucky to meet and spend time with.”

Speaking to reporters after the president's hospital visit, Brown said that the president had done "the right things" during his time there, adding that some had told him privately that they were not admirers of the president, but that they had "showed respect for the office."

"He was received well by the patients, as you’d expect. They were hurting, he was comforting," said the senator. Both he and Whaley said they had suggested to Trump that he press for gun control legislation.

In El Paso, the president slammed both Ohio politicians. "I had it with Sherrod Brown," he said, adding that the senator and Whaley were "very dishonest people and that’s probably why he got, I think about zero percent and he failed as a presidential candidate.”

White House press secretary Stephanie Grisham told the Daily Mail that Brown and Whaley were "playing up what little conversation they had [with the president], saying they made comments or demands and that's just not true. The president allowed them to be part of the entire visit, which was very gracious of him. Their little press conference was clearly premeditated and not in the best interest of anyone but themselves. It's a disservice to this country, and I have a real problem with that."

She later told CNN it was "disgusting" that Brown and Whaley had not noted that those at the hospital were "so happy" to have the president and first lady visit.

Brown brushed off the criticism. “I’ve said before Donald Trump is a bully and bullies are cowards," he said in a statement. "I don’t care what he says about me. But the people of Dayton deserve a president more focused on protecting them from gun violence than protecting his own ego.”

Grisham told reporters traveling with the president that they could not accompany him inside the hospital because the visit was "never intended to be a photo op." Shortly after Trump left, however, he and White House social media director Dan Scavino both tweeted out an edited video and photos of Trump being greeted by hospital staff and visiting survivors of the shooting.

Trump also tweeted aboard Air Force One that a speech Wednesday by former Vice President Joe Biden in Iowa accusing the president of trying to destroy the foundations of America was “sooo boring!,” and criticized Fox News anchor Shepard Smith for his ratings.

Earlier in the day, Trump denied that his rhetoric was divisive, saying that he had toned down some of his words, but that he believed his language “brings people together.”

"Our country is doing incredibly well," he added.

Shortly before Trump left the White House for El Paso and Dayton, he tweeted that O'Rourke used a "phony name to indicate Hispanic heritage" and told him to "be quiet!"

O'Rourke, whose full name is Robert Francis O'Rourke and has long been called by his childhood nickname "Beto," responded in a tweet: “22 people in my hometown are dead after an act of terror inspired by your racism.”

The president's visits drew criticism from elected officials in Texas and Ohio over his lack of action on gun regulations and his divisive stance toward immigrants. Protests took place in both cities.

Outside the Dayton hospital, protestors inflated a large balloon of Trump as a baby, with signs reading "you are why" and "words have consequences." Another group of protestors gathered near the site of the shooting, chanting, "Do something."

In El Paso, GOP volunteer Jeri Hallberg — an in-law of shooting victim Angelina Englisbee — said it was too soon to be discussing the politics surrounding the shooting.

“This is the time for people to acting in a humanitarian way, not pointing the finger,” Hallberg said.

Asked whether it was too soon offer criticism of the president, Rep. Veronica Escobar, D-Texas, said it was "too late."

"We have 22 funerals ahead of us, and it’s too late," said Escobar. "Demanding that the dignity and grace of every human being be acknowledged should not be a partisan issue."

Before leaving the White House, Trump said criticism of him after the two shootings was politically motivated, and he placed the blame for the scourge of mass shootings that have marked his presidency on mental illness and a culture of violence.

“These are people who are looking for political gain, and as much as possible I try to stay out of that,” Trump told reporters.

Trump said that he supported stronger background checks and limits on allowing people with mental illness to have access to guns. He said that he believed Congress would be able to reach a deal on gun control legislation, but that he did not expect it to include limits on assault-style weapons.

“I have had many talks over the last few days, and I think we are going to come up with something that’s gong to be really, really good,” Trump said.

As he departed El Paso, the president had another thought — about another critic, Rep. Joaquin Castro, D-Texas "I don’t know who Joaquin Castro is other than the lesser brother of a failed presidential candidate (1%) who makes a fool of himself every time he opens his mouth," he tweeted shortly after Air Force One departed, after deleting an earlier tweet that incorrectly identified the congressman as "Juaquin." " Joaquin is not the man that his brother is, but his brother, according to most, is not much. Keep fighting Joaquin!"

Suzanne Gamboa reported from El Paso, Texas