MEXICO CITY  Prisoners in a northern Mexico jail were allowed out at night to carry out murder-for-hire jobs using jail guards’ weapons and vehicles, officials said Sunday, revealing a level of corruption that is stunning even in a country where prison breakouts are common as guards look the other way.

The prisoners carried out three massacres this year in the city of Torreón in which 35 people were killed, Ricardo Nájera, the spokesman for the attorney general’s office, said at a news conference. Among them, the authorities said, was last week’s attack on birthday revelers at a party hall. The gang shot randomly into the crowd, they said, killing 17 people.

Ballistics studies confirmed that four guns used in the shooting were the same as those assigned to jail guards, Mr. Nájera said.

“The criminals carried out their executions as part of a settling of scores against members of rival gangs linked to organized crime,” he said. “Unfortunately, in these executions the criminals also cowardly murdered innocent civilians  and then returned to their cells.”