Five medical students found dead inside a vehicle, their bodies bearing signs of torture.

Four bystanders fatally shot by gunmen who fired at a hair salon.

Eleven young people gunned down by criminals who shot up a holiday party.

The recent attacks — all in the past month — are the latest in a string of mass killings in Mexico that have drawn renewed attention to the government’s struggle to control the violence raging across the country.

“Wherever you look, there is a nephew, a brother, a friend dead,” said Angélica Zamudio Almanza, whose nephew was killed in the shooting at the holiday party on Sunday in Guanajuato, one of the most violent states in Mexico.

She was, she said, “between fear, helplessness, rage.”

In the run-up to a crucial presidential election in Mexico next summer, violence has become perhaps the single most important political issue in the nation, where polling shows insecurity is the population’s top concern and the ruling party faces pressure to show progress in its fight against increasingly powerful drug cartels.

Preliminary investigations offer few clues about whether some new dynamic in the criminal underworld is behind the recent spate of mass killings. What is clear, analysts say, is that they are all driven by one constant that no Mexican leader has touched: almost total impunity for criminals.

Less than 4 percent of criminal investigations are ever solved in Mexico, studies show, and about 92 percent of crimes went unreported in 2022.

“The criminals are emboldened, because they know there’s practically zero chance of facing any punishment,” said Eduardo Guerrero, a Mexico City-based security consultant. “They know they can do whatever they want, that’s the common denominator.”

The cartels’ dominance has also become a focus for American officials, with Republicans threatening to invade Mexico to combat the criminal groups and concern growing in Washington that criminal groups’ attacks on communities are adding to the tidal wave of migration at the southern border.

“When you see a breakdown in the ability of security services to protect civilians, when it isn’t just cartel-on-cartel violence, it has to matter to the United States,” said Roberta Jacobson, a former U.S. ambassador to Mexico. “No. 1, probably for this administration, because it will drive migration if people are displaced.”

An extraordinary number of Mexican families — nearly 160,000 — were caught crossing the southern border illegally from October 2022 to September, four times as many as in the previous year, according to U.S. government figures. The influx, migration experts say, was spurred in part by cartels forcing people out of their homes with threats of recruitment, extortion or death.

Mexicans’ resentment of their criminal overlords has reached a boiling point in some parts of the country.

This month, farmers in central Mexico unleashed their rage on gang members who were trying to extort them, using machetes and rifles to chase down and kill 10 suspected members of a local cell of the Michoacán Family cartel, officials said.

Some on social media celebrated the incident, which was partially caught on video, as a triumph of regular citizens over their tormentors in the face of an absent government.

But the revolt came at a cost.

Even though President Andrés Manuel López Obrador sent hundreds of soldiers to the area, the cartel’s pursuit of revenge has prompted more than 100 families to flee their homes in fear, according to local news media reports.

Mr. López Obrador came to office in 2018 promising to overhaul the country’s approach to crime, with an emphasis on addressing the poverty that drives young people to join gangs in the first place rather than aggressively confronting the cartels in the streets.

The strategy, which Mr. López Obrador called “hugs, not bullets,” has had some success, analysts say. Over the last five years, homicides have modestly declined and surveys show that people in cities feel safer than they did under the previous president.

“They left us with high homicides,” Mr. López Obrador said this month, referring to his predecessors. “But we brought them down and they’ll continue to go down.”

Still, reports of extortion and of missing people have shot up since 2018, and killings are still close to the highest levels recorded.

The president has also stoked anger by suggesting, without offering evidence, that those killed in high-profile attacks were somehow themselves involved in with drugs.

Three days after the medical students were found dead in the city of Celaya, in Guanajuato state, Mr. López Obrador said at his regular nationally televised news conference that the young men were killed “because they went to buy from someone who was selling drugs in a territory that belonged to another gang.”

Local officials later said the investigation showed the crime had nothing to do with a drug sale, and Fabiola Mateos Chavolla, the mother of two of the victims, lashed out at the president for his “cruel and irresponsible comments” about her sons, saying Mr. López Obrador had “blamed them for their death.”

This week, days after the attack on the holiday party, the president again pointed to “drug consumption” as an explanation.

Ms. Zamudio Almanza, whose nephew, Galileo Almanza Lezama, 26, was gunned down in the attack, was angered by Mr. López Obrador’s comment.

“Faced with his own ineptitude, he has nothing else to say other than to revictimize people,” she said of the president.

The victims of the recent outbursts of violence were killed for different reasons, preliminary investigations suggest: The medical students crossed paths with criminals at a water park; the bystanders at the hair salon were in the wrong place at the wrong time; the partygoers offended young men who were willing to massacre them in revenge.

The wife of Juan Luis García Espitia, an audio engineer who was killed Saturday while working for the band that was playing at the holiday party in Salvatierra, in Guanajuato, said she wanted her husband’s killers punished.

“I don’t know how to tell my daughters if I don’t even have the words,” said the mother of three, who would only give her first name, Jazmín, out of fear of reprisals. “I don’t know how to explain to them that their dad is not going to be here anymore.”

She added: “I will not get my husband back, but I would like justice.”

Miguel García Lemus contributed reporting from Salvatierra, Guanajuato.