MEXICO CITY — One of two priests shot to death in a road ambush had been photographed earlier holding an assault rifle in the company of armed, masked men, a prosecutor in southern Mexico said Tuesday.

Xavier Olea, the head prosecutor for Guerrero state, said the two priests went to an open-air concert Monday attended by members of various drug gangs. Olea said the priests were drinking, which he called “an indiscretion.”

The two were shot to death along with four other people when gunmen attacked their truck as they returned home from the concert.

Olea said that there was a fight at the concert involving the priests’ group of acquaintances and that the priests were killed apparently by gunmen from one of the gangs.

He said the photograph of the priest, Father Germain Muniz Garcia, with the assault rifle led the gunmen to think he was associated with a rival gang. He said the photo circulated on social media with messages, presumably from other gangs.

Bishop Salvador Rangel, who oversees the diocese where Muniz Garcia was assigned, criticized the prosecutor’s comments.

“I do not agree that they want to link Father Germain with drug traffickers because of one photograph that is circulating out there,” he said.

Some say drug gangs so dominate the area that priests have to avoid conflict with them to attend to parishioners. The bishop told The Associated Press he had been in contact with the leaders of some gangs trying to keep his priests safe.

“I have said it openly: I have talked to the capos, with the leaders of these groups, in order to take care of the priests, nuns and seminary students,” Rangel said. “I have always talked about dialogue in the search for peace.”

In previous killings of priests, Mexican prosecutors have appeared to rush to associate the slayings with the victims’ use of alcohol. Church leaders have called some of those comments an attempt to smear slain priests.

Mexico has been an exceedingly dangerous place for priests, especially in Veracruz, Guerrero and Michoacan states. Mexico’s Catholic Media Center says 21 priests have been killed in Mexico since December 2012, including the two priests killed Monday near the tourist town of Taxco, south of Mexico City.