MEXICO CITY — The U.S. State Department has warned its citizens about traveling to Cancun and Los Cabos, two of Mexico’s most popular tourist destinations, after a spike in violence in those regions.

A travel advisory upgraded the warnings for two states, Quintana Roo and Baja California Sur, saying turf battles between criminal groups have resulted in shootings in which innocent bystanders have been killed.

For years, both regions were largely spared the drug war violence that has engulfed other parts of Mexico, but this year they have seen a major uptick in killings.

There have been deadly gun battles in downtown Cancun, and in January, five people were killed at a nightclub in nearby Playa del Carmen. In Los Cabos, three people were shot to death this month at the entrance to a popular beach.

The travel warning is a major hit to Mexico’s $20 billion-a-year tourism industry, of which the regions surrounding Cancun and Los Cabos are crown jewels. Mexican tourism authorities have gone to lengths to portray the beach resorts as family friendly and safe. Each year 10 million tourists visit Quintana Roo, the state where Cancun is located.

But 10 years into the country’s military-led drug war, violence is surging across the nation. This year, Mexico is on track to record more homicides than in any year in the last two decades.

Rising demand for heroin in the U.S. and power struggles among the country’s top drug cartels, authorities say, have led to an increase in killings in 27 of Mexico’s 32 states.