By Simon Romero and Rick Rojas, New York Times–

Earlier this year in his State of the Union address, President Trump described to the nation how the Texas border city of El Paso once had “extremely high rates of violent crime” and was considered “one of our nation’s most dangerous cities.” Then he turned it into the living argument for his border wall.

“With a powerful barrier in place,” he went on, “El Paso is one of the safest cities in our country. Simply put, walls work and walls save lives.”

In this West Texas border city, founded 360 years ago as an outpost of the Spanish empire, those words festered. So did words Mr. Trump repeated at a rally he held on the city’s outskirts a few weeks later. “Murders, murders, murders,” he said, in reference to immigrants, as the crowd chanted, “Build the wall!”

For many in El Paso, the potentially devastating consequences of the anger over immigration and race became apparent this weekend, when 22 people were killed at a Walmart and the white suspect warned of a “Hispanic invasion,” plunging the city into mourning. So Mr. Trump returned — this time to say he wanted to help the city grieve.

But rarely in recent memory has a relationship between a president and a city been so fraught. As Mr. Trump arrived here on Wednesday to try to meet the victims, protesters gathered at a memorial outside the scene of the carnage, many angry at the president’s visit.

The El Paso Times published a letter to Mr. Trump defending the city — which lies just across the border from the Mexican city of Ciudad Juárez — and its deep sense of bicultural identity. “Our city and Juárez were always linked. Today, we are intertwined more than ever. The evil that visited us targeted people from El Paso and Juárez alike,” it said. “Our people are scared.”

And so this predominantly Hispanic city in a state whose leadership is tightly aligned with the administration’s anti-immigration agenda tried this week to chart its own course through America’s troubled political waters.

El Paso officials — pointing out that the Trump campaign still owes the city more than half a million dollars for the security costs of a rally in February — veered between rejecting the president’s politics and welcoming his attempt to recognize the city’s grief.

“This is the office of the mayor of El Paso in an official capacity welcoming the office of the president of the United States, which I consider is my formal duty,” said Dee Margo, the mayor.

Others in the city had no patience for such diplomacy.

“Absolutely everything that Trump stands for was concentrated and fired at the citizens of El Paso that day at Walmart,” said Christopher Bailey, 43, a project coordinator for an El Paso health clinic. “Shame should be hung around the neck for every supporter that continues to justify his language and his presidency.”

At the memorial outside the Walmart that was the scene of Saturday’s attack and at a poster-making event the night before the protest, many said the president should not have come.

“It’s his words that created the climate that led that hateful man to come to my community,” said Lyda Ness-Garcia, a lawyer and an organizer for the Women’s March of El Paso who was at the poster event.

She said that when Mr. Trump painted El Paso as a dangerous city that needed stronger barriers between it and Mexico he was using the city as nothing more than a prop. El Paso was one of the safest American cities of its size long before barriers went up at the border, and violent crime is relatively low.

“It’s factually false. It’s just untrue. It’s nothing but some mythed-up white rage,” she said. “He needs to apologize and take his words back.”

In an extraordinary series of tweets on the night before the president’s arrival, Representative Veronica Escobar, a Democrat representing El Paso in Congress, underscored the way in which the city was taking on a leading role — even in a conservative state like Texas — in opposing Mr. Trump. Only about 26 percent of the voters in El Paso County voted for Mr. Trump in 2016.

Ms. Escobar revealed that the White House had invited her to join Mr. Trump during Wednesday’s visit, but she said she had requested a phone call with the president in an effort to explain that the language he uses to describe Latinos, sometimes equating them with violent criminals, is dehumanizing.

“I have publicly said he has a responsibility to acknowledge the power of his words, apologize for them, and take them back because they are still hanging over us,” Ms. Escobar wrote.

The president, she said, was “too busy” to talk, and she declined to join him in his visit. “I refuse to be an accessory to his visit.”

El Paso treasures its place as part of a community that straddles two countries. Its vibrancy, many said, comes from its bond with Mexico, with a history that is older than that of the United States.

“He doesn’t really know who we are,” said Judy Lugo, president of the Texas State Employees Union, which represents some 10,000 state workers, of Mr. Trump’s visit. “He doesn’t know our culture, the long history we have. He doesn’t understand.”

“We are a community of love, a community of family,” Ms. Lugo said. “We are not what he says we are. We are not rapists. We are not dirty. We are not criminals.”

Across the city, some residents worried that Mr. Trump’s visit might do more harm than good.

“He’s just putting salt on the wound,” Ninamarie Ochoa, 29, a teacher, said of Mr. Trump’s visit. Referring to white nationalists who express views like those of the suspect in the attack and the recent detention in tent camps of thousands of migrants arriving in El Paso, she said, “I think that the way he has empowered those voices, to give them license to act on it, you see this in the way that people talk about ICE and Border Patrol and their complacency with the concentration camps.”

Wednesday’s visit was intended as an opportunity for Mr. Trump to console family members and survivors and help commemorate those who died in Saturday’s attack. But few seemed ready to bridge a gap between the city and the president that had grown wide even before the shooting.

El Paso’s culture has been influenced both by its proximity to Mexico and its distance from so much of the rest of the state, said Richard Pineda, a political communications professor at the University of Texas, El Paso. In a previous era, before jet travel, a trip to El Paso from many cities could be 10 hours or more. It still takes 11 hours to drive there from Houston. It is in a different time zone than the rest of Texas.

The city, he said, was not as tolerant as some might portray it. Yet a certain influence comes from living so close to another country, with the vibrancy, poverty and sometimes violence of Ciudad Juárez visible on the other side of the border fence. “You literally get to see a totally different world,” he said.

As Mr. Trump has used El Paso as a stage for promoting his immigration policies, some of the city’s politicians have used it as an example of a counternarrative. The city’s former representative in Congress, Beto O’Rourke, now running as a Democrat for president, often talks about El Paso’s experience as a bicultural city to criticize the administration’s handling of the surge in migrant arrivals at the southern border. Ms. Escobar has made frequent appearances on television condemning the treatment of migrants in crowded detention centers, many of them in El Paso and nearby.

Yet some of Mr. Trump’s messages have found support in El Paso — though few were eager to talk about it much in the mood of grieving and anger that prevailed on Wednesday.

Jordan Flores, 20, who buses tables at Peter Piper Pizza, showed up outside the Walmart wearing a MAGA hat. He said he remained a supporter of the president, though he felt uneasy about the killings.

“For people to put me into the rhetoric that I am supposed to be this racist or homophobic person, it’s just not true,” Mr. Flores said. “My heart goes out to every single person that was affected by this massacre.”

Jason Carr, 53, who described himself as a libertarian, said it was clear even to him that it would have been better for the president not to have come to El Paso.

“It’s pretty clear he wasn’t wanted,” he said. “You can see the hurt in people’s eyes,” he said of the attack, still so fresh after only a few days. “It’s just so wrong. There’s just so many layers of how wrong it was.”

Arturo Rubio and Erin Coulehan contributed reporting.