Prison guards loaned their own weapons to the killers, who went on to slay 17 at a birthday party in Coahuila state, authorities say. Inmates from the same prison are suspected in other attacks.

Reporting from Mexico City — Prison inmates allowed to leave their cells with weapons borrowed from guards carried out last week's killing of 17 people in northern Mexico, federal authorities said Sunday.

Ricardo Najera, spokesman for the federal attorney general's office, said prison officials in the northern state of Durango lent the inmates weapons and official vehicles to carry out several tit-for-tat killings on behalf of organized crime.

The deadliest was the July 18 attack on a birthday party at an inn in Torreon, in neighboring Coahuila state. Gunmen sprayed gunfire at revelers who had been summoned by an invitation on Facebook.

Authorities have not specified a motive for the attack, which also left 18 people wounded.

Mexican prisons, overcrowded and poorly run, are hotbeds of violent criminal activity, including telephone extortion schemes and drug operations. Allowing inmates out to act as hit men would mark a new extreme.

Najera said inmates from the same prison, in the Durango city of Gomez Palacio, are suspected in shootings this year at a pair of bars in Torreon, which sits across the state line, that killed a total of 18 people.

Four prison officials, including the director, Margarita Rojas, and the security chief, were being held under a form of house arrest as the investigation continued.

"The criminals carried out the execution as part of a settling of accounts against members of rival gangs tied to organized crime," Najera said during a news conference. He said "innocent civilians" also were killed.

The inmates returned to their cells after the attacks, Najera said.

It was not immediately clear how many prisoners or guards might have been involved in the shootings.

Federal authorities said their investigation of guards at the Durango prison had turned up four AR-15 rifles that matched shells from the July 18 slayings.

The charges point to the staggering official corruption confronting Mexican President Felipe Calderon's war on drug cartels.

The anti-crime campaign, launched in late 2006, is already beset by widespread police graft, especially at the state and local levels, where many officers moonlight as enforcers for trafficking groups.

Mexico's new interior minister, Francisco Blake, said the episode was a reminder of the "state of deterioration" afflicting many local law-enforcement institutions.

Blake vowed to investigate who gave the orders for "these cowardly and condemnable acts."