MEXICO CITY—President Felipe Calderón met in Washington on Thursday with President Barack Obama in an attempt to repair relations at a time when spiraling violence in Mexico's drug war has frayed ties between the two allies.

The meeting comes just three weeks after a U.S. Immigration and Customs Enforcement Agent was killed and another wounded by alleged drug gunmen. Jaime Zapata, the slain ICE agent, was the first U.S. law-enforcement official to be killed in the line of duty in Mexico in a quarter century.

 Mr. Calderón's visit, announced last week, also comes after a spate of ill-timed comments by U.S. officials about Mexico's drug violence. Among them are that Mexican drug gangs could be allied with Islamic terrorists and that drug traffickers could overthrow the Mexican state, forcing the U.S. to send troops. Such statements have enraged Mexican officials, who are notoriously sensitive to any suggestion of U.S. interference in national affairs.

"I don't recall this kind of bad blood in a long time," said Jorge Castañeda, a former Mexican foreign minister.

At home, Mr. Calderón has also been feeling political heat. As Mexico enters its 2012 presidential electoral season, polls show the government's inability to halt rising violence, even as it kills or captures drug kingpins, increasingly worries Mexicans. That's a blow to the president, who has made security the centerpiece of his government program.

Analysts believe that weary Mexican voters may reject the candidate from Mr. Calderón's center-right party and vote to bring back the Institutional Revolutionary Party—anathema to Mr. Calderón—which controlled Mexico for most of the 20th century and whose presumed candidate is leading in the polls

More From News Talk KIT