MEXICO CITY — For years, officials in northern Mexico watched as a border wall rose just north of the Rio Grande, and as the White House threatened repeatedly to freeze cross-border traffic.

Now, with coronavirus cases soaring in the southwestern United States, it’s Mexican leaders asking for tighter border enforcement to keep their communities safe.

“The situation is very bad in Texas and (cross-border travel) would only bring us problems in northern Tamaulipas,” said Javier García Cabeza de Vaca, the governor of Tamaulipas state who tested positive for the virus this past week.

García Cabeza de Vaca and other border governors have pleaded with Mexico’s central government to better vet people entering Mexico from the United States, to ensure that their trips qualify as “essential travel.”

While the United States has applied that designation relatively strictly since March — allowing entry only to noncitizens and nonresidents whose jobs are deemed critical — Mexican border officials rarely question travelers entering the country. As a result, hundreds of thousands of Americans have continued crossing the border into Mexico for recreational purposes — including visiting relatives and going shopping. Mexican officials were worried such visits will surge during the Fourth of July weekend, a dangerous vector for the virus to enter the country from the United States.

As cases have increased in Southern California, Arizona and Texas, Mexican border states have increasingly come to see the outbreak in the United States as their biggest threat in controlling the epidemic.

Citing no evidence, President Donald Trump has said that the border wall would keep infections from entering the United States from Mexico. But given the soaring U.S. caseload, it is Mexico that has more reason to fear the virus coming across the border.

On Thursday, the Mexican government said it would be installing “sanitary filters,” where travelers from the United States will have their temperatures checked at several border crossings. Those checkpoints have “the goal of protecting the health of the Mexican population, particularly those in the border states,” said a statement from the country’s foreign ministry.

Mexican officials in border states have gone further, pleading for people not to cross the border at all.

Enrique Clausen, Sonora state’s health minister, said he would seek to apply more stringent controls on border crossings than those mandated by Mexico’s federal government.

“It’s so important to implement the necessary measures to protect the health of Sonorans. And one of them, at this moment, has to be reducing the border crossings from the United States toward Mexico,” Clausen said during a news briefing Tuesday. Two days later, he too tested positive for the virus.

On Thursday, the U.S. ambassador to Mexico, Christopher Landau, echoed that message in Spanish, addressing U.S. citizens living along the border in a video posted on Twitter. He advised Americans to avoid cross-border travel during the Fourth of July weekend.

“In recent weeks, hundreds of thousands of people have crossed the land border every day and 90 percent of them are U.S. citizens or green-card holders,” he said. “If this traffic doesn’t decline, there will be an increase, not a decrease, in travel restrictions.”

The U.S. government has continued deportations to Mexico throughout the pandemic. In many cases, deportees have tested positive for the coronavirus after entering Mexican territory. Those deportations have further infuriated Mexican officials who have tried to restrict Americans from visiting the country.

“Why are they continuing these deportations in the middle of a deadly pandemic, including people who are already sick and who knows how many asymptomatic people,” Maki Ortiz, the mayor of the Mexican city Reynosa, told The Washington Post in May.

U.S. border states have a significantly higher rate of infection than Mexican border states, although with limited testing in Mexico, it is difficult to compare the numbers.

Tamaulipas, with a population of 3.5 million, has had 5,712 confirmed coronavirus cases. Sonora, with a population of 2.85 million, has had 7,064

Texas has a population of 29 million and more than 175,000 confirmed coronavirus cases. Arizona has a population of 7.3 million people and more than 90,000 confirmed coronavirus cases.

In June, Trump said at a rally in Phoenix that the Mexican city of Tijuana was “heavily infected with COVID” and that the border wall was preventing cross-border transmission. In fact, San Diego had more cases of the virus per 100,000 residents.

Some U.S. citizens and permanent residents who live in Mexico are crossing the border to be treated in American hospitals, placing a disproportionate stress on small community hospitals in places like Imperial County, Calif. U.S. border restrictions still allow Americans to cross the border into their own country without citing a reason.