EL PASO, Texas — For many years, Texas’ westernmost city has been a place where Latinos have felt comfortable in their skin.

While El Paso hasn't been spared racism and conflicts over immigration crackdowns, its residents have relished in the border city’s bicultural, bilingual and binational essence, their embrace of diversity as well as its low violent crime rate, at or below the national average since about 2012.

Then El Paso ended up in the crosshairs of a man who opened fire in a Walmart on Aug. 3, leaving 22 people dead and dozens more injured. After his arrest, the suspected gunman told authorities that he wanted to kill Mexicans. Before the attack, the suspect is believed by authorities to have posted a hate-filled diatribe decrying a "Hispanic invasion."

The massacre punctured El Paso's security bubble, which residents were grateful for each time they'd hear or read of cartel violence across the border or in other parts of the country.

"El Paso was an escape. It was a cool place to live, a very nice place to live, and now that the narrative is changing, it really effects you to the core of who you are," said Jeramy Maynard, 26, a native El Pasoan. "Now there is no escape."

A history of violence stoked by rhetoric

Yet some see the shooting as another sad chapter in a U.S. legacy of racial violence, suppression and discrimination — including language that paints Hispanics as foreigners and criminals.

“This violence against Latinos and immigrants has a long history since the founding of the country,” said Texas state Sen. José Rodriguez, an El Paso Democrat.

Historically, the violence was stoked by rhetoric from politicians and local Anglo residents who criminalized anyone who looked Mexican as people who didn't belong in the United States and who were inherently violent, said Monica Muñoz Martinez, author of “The Injustice Never Leaves You: Anti-Mexican Violence in Texas.”

Shoppers exit with their hands up after a mass shooting at a Walmart in El Paso, Texas, on Aug. 3, 2019. Jorge Salgado / Reuters

Because the violence often was sanctioned by the state government, carried out by the Texas Rangers (the state law enforcement arm), U.S. soldiers and local law enforcement, they were able to carry out the violence with impunity and a cloak of legal authority, Martinez said.

The oft-cited case, and one that actually was investigated in a legislative hearing, is the Porvenir massacre in 1918, in Presidio County, southeast of El Paso County.

Texas Rangers working with ranchers raided the Mexican American community of Porvenir in the middle of the night, separated men and boys from their families and massacred them while they were under arrest and in custody of the Rangers, Martinez said.

The press at the time portrayed those massacred as bandits, criminals and squatters, even though they were farmers and ranchers, and the Rangers had visited the community days before the raid to make sure the families were unarmed, Martinez said. There were never any prosecutions.

Because the victims were criminalized in death by officials and the press, survivors had trouble seeking justice.

Although the massacre was one of the more sensational events in the area, Texans of Mexican American descent were killed in custody throughout that era or "disappeared" or "evaporated," Martinez said.

During a 1919 congressional investigation into Texas Rangers violence, U.S. Rep. Claude B. Hudspeth, a Texas Democrat, spoke against curtailing the Rangers' authority against Mexicans crossing the Rio Grande. Mexico was in the midst of its revolution at the time.

"A Ranger cannot wait until a Mexican bandit behind a rock on the other side shoots him three or four times, ... You have got to kill those Mexicans when you find them or they will kill you," Hudspeth stated for the investigation, according to Martinez's research.

Martinez said this rhetoric helped push beliefs that all Mexicans were bandits that "necessitated extralegal violence" in response. Hudspeth, after whom El Paso County's neighboring county is named, went on to add $1 million to an appropriations bill to establish a "land border patrol" to police the borders with Mexico and Canada, Martinez wrote.

In launching his 2016 campaign for president, Donald Trump said the people Mexico "sent" to the United States were not its best, but were "rapists" and people bringing crime, drugs and problems. Those who attend his rallies regularly shout "build the wall," and he once said people coming into the country are not people, but animals.

“What’s troubling is, what you see today, the forms of vigilante violence like policing the border, they are responding to the rhetoric by state and federal officials who are stoking fear,” Martinez said. “The racist rhetoric, focusing specifically on people who are Latino, creates a public acceptance of violent border policing and nativist immigration policies.”

El Paso's congresswoman, Veronica Escobar, a Democrat, said state officials and conservative media "have really pushed the racist, xenophobic description of Mexicans and immigrants in a way that has been deeply frightening for me for a long time."

Lynchings, land grabs, "Juan Crow" laws

Campaigns against Latinos have come in many forms over the years.

Rodriguez, the state senator, ticked off a partial list: the lynchings of Mexican Americans and Mexicans, the taking of Mexican Americans’ land in what are now Texas, California and other places, and violence against farmworkers.

From 1848 to 1928, at least 232 people of Mexican descent were killed by mob violence or lynchings in Texas — some committed at the hands of Texas Rangers, according to research by William D. Carrigan and Clive Webb, authors of “Forgotten Dead: Mob Violence Against Mexicans in the United States.”

A Texas segregation sign reading "We Serve White's Only No Spanish or Mexicans" in Dimmit, Texas. Signs like these were displayed at various restaurants and other pubic accommodations under a system known as "Juan Crow" laws which were patterned after Jim Crow laws and made to enforce the racial discrimination practiced against Mexican Americans. Russell Lee / Dolph Briscoe Center for American History

El Paso's nickname is "El Chuco," short for "pachuco," a reference to a 1940s subculture of Mexicans and Mexican Americans who adopted their own style of dress that included zoot suits of the jazz culture.

Believed to have started in El Paso and the adjacent city across the border, Ciudad Juarez, pachuco culture spread west. But the pachucos were labeled gang members, and in 1943 service members attacked zoot-suit wearers in several acts of mob violence that became known as the Zoot Suit Riots. Press accounts blamed immigrants and gangs and only victims were arrested.

For years, Mexican Americans were subject to so-called Juan Crow laws — similar to Jim Crow laws used against African Americans — that forced them to go to inferior "Mexican schools" and prohibited them from entering "whites only" theaters, swimming pools, restaurants and parks.

Rodriguez, whose state Senate district takes in El Paso County and a few other counties on the border and in west Texas, said he was a sophomore in high school in 1966 when farmworkers in melon fields went on strike to unionize and improve wages and work conditions. Texas Rangers and local law enforcement harassed, beat and arrested them to crush the strike.

The Supreme Court ruled against the Rangers in a civil rights case, Allee v. Medrano. In its opinion, the court described how the Rangers took into custody two people protesting at the Missouri-Pacific Railroad and "as a train passed, the Rangers held these two prisoners' bodies so that their faces were only inches from the train," the court said. A congressional committee also found the Rangers used excessive force.

Amid progress, lingering racial rhetoric

El Paso helped the nation progress in civil rights: A lawsuit brought the integration in 1955 of what was then Texas Western College and is now the University of Texas at El Paso. Nearly a decade later, the college's legendary basketball coach, Don Haskins, fielded an all-black starting lineup in an NCAA championship game, which Texas Western won.

But El Paso has also had to contend with racism on its homefront. In 1991, a federal judge ruled that Border Patrol agents violated the civil rights of students and staff at Bowie High School by stopping them without cause to investigate their citizenship. In one incident, an agent held a gun to the head of an assistant coach who was driving students to a football game.

Politicians continue to paint border areas like El Paso as a violent threat. For years, members of Congress have pushed for increased border enforcement funding as they have charged that cartel violence in Mexico was spilling into the United States.

The governor has sent National Guard troops to the border, supplementing Trump's deployment of military troops there. Texas has spent about $800 million every two years since 2015 to stage state troopers in border counties.

Jose, 27, with his son Jose Daniel, 6, is searched by U.S. Customs and Border Protection Agent Frank Pino, in El Paso, Texas. Paul Ratje / AFP - Getty Images file

More recently, El Paso has been asserting itself politically on a national scale: electing Escobar as one of the first two Texas Latinas in Congress and rallying behind its former congressman, Beto O’Rourke, in his failed attempt to oust Ted Cruz, one of the red state’s GOP U.S. senators, and now in O'Rourke's run for president.

"In El Paso, we see ourselves as a place of opportunity, security and pride, a place that exemplified everything that is great about this country: hard work, devotion to family and commitment to people," Escobar said.

In 2018, El Paso voters more than doubled their turnout from the 2014 midterm elections and nearly matched their 2016 presidential election turnout.

But as El Paso was more forcefully asserting itself politically, it found itself the target of Trump, who falsely portrayed it as unsafe before a border wall was built and used it as a starting place for separating migrant children and parents at the border as he decried an "invasion" was taking place.

Artemio Muniz, chairman of the Federation of Hispanic Republicans, an arm of the Texas Republican Party, said every racial, ethnic, religious or other group has examples of suppression. But he acknowledges there is "a very dangerous level of rhetoric" in the party, not just from Trump but at the grassroots level.

Despite the fact that Hispanics, particularly Mexican Americans, have always been an intrinsic part of Texas and even helped win its independence from Mexico, Muniz said similar talk is constantly being touted by some grassroots Republicans. "These are groups that have come into the party, even though they are a small minority, taken the Republican brand and defiled it," he said. Hispanic Republicans have supported the party despite this rhetoric as long as their interests are represented, Muniz said.

The Aug. 3 massacre at the Walmart came as El Paso was "standing up for herself," Escobar said. "We have been made a target for a long time by politicians who want to paint the border as a place to be feared, to be controlled and constrained."

Muniz said there is a need for border security, pointing to a shootout in Houston between drug traffickers and law enforcement in an undercover operation that turned into an ambush. Any sort of immigration reform needs to address the fact that issues with drug trafficking are real, he said.

But too often, Muniz said, he's heard talking points and language similar to the screed linked to the El Paso suspect — warning against Hispanics' replacing whites, taking over the government and turning Texas into a Democratic stronghold — and he's heard it in state convention meetings and has seen it used to drive Republican Party policy.

"We can sit here and say Trump," he said, "but it's been going on for years."

Follow NBC Latino on Facebook, Twitter and Instagram.