Mexico's drug war isn't just a conflict between the government and heavily-armed cartels. There's a third faction: vigilantes who have proliferated across nearly half of Mexico's states and dozens of municipalities, and who operate in the space between the law and the lawless. Now the vigilantes are getting legalized.

This week, Bruno Placido – the leader of one of Mexico's largest militia groups – signed an agreement with Angel Aguirre, governor of the state of Guerrero, to effectively legalize Placido's army of 800 vigilante fighters. Called UPOEG, for "The Union of Peoples and Organizations of the State of Guerrero," the militia went from being a community activist group five months ago to a force of hundreds of armed vigilantes that promised to expand further.

According to El Universal, the details are still being worked out, but the plan is to regulate the militia under a "Community Security System" where the fighters are to coordinate with local, state and federal police, not agitate for political causes, and not patrol outside their own communities. In exchange, the plan sets up "training in human rights and protection and self-defense strategies, that will be taught by the Mexican Army."

It's not hard to see why the authorities are trying to reign the militias in, as they've become a new, distinct but loose-knit faction in the drug war, spread across at least 13 of Mexico's 31 states and heavily concentrated in the country's rural south and southwestern regions. They've expanded rapidly in recent months – the vigilantes claim it's out of necessity owing to the threat from the drug cartels – with UPOEG reportedly declaring plans to move against the cartels operating in the resort city of Acapulco Local cops, meanwhile, have been accused by the UPOEG of being corrupt and slow to respond.

More practically, UPOEG and militias like them function as volunteer cops, and armed with machetes, hunting rifles and shotguns instead of service pistols.

Their job: chasing out drug traffickers, and handing captured gangsters over to the authorities – if they hand them over. The militias are also known for dispensing a sort of street justice, with their own jails, courts and allegations of executions, beatings and torture of alleged criminals.

It wasn't too long ago when the vigilantes were more likely to seize towns than agree to stay local. After a UPOEG commander was killed in late March, more than 1,500 vigilantes assembled around the highway town of Tierra Colorado, between Mexico City and Acapulco. The fighters reportedly set up checkpoints around the town and arrested 12 police officers, including the town's former police commander, who was later freed. They also shot a tourist who didn't stop at one of their checkpoints.

Bad as that sounds, it's fairly tame compared to what's happened elsewhere.

In February, Mexican troops raided jail used by another militia in the state of Michoacan, arresting 30 militiamen and freeing six police officers who were to be put on a "public trial," according to Proceso. The militia retaliated by capturing 47 soldiers, who were later freed after the government agreed to appoint public defenders for the militamen.

"This is a country that's trying to work overtime to revamp its image as a series of corrupt and opaque institutions," Sylvia Longmire, a border security consultant and former Air Force intelligence analyst, tells Danger Room. "I guess it's one step towards transparency by legitimizing these groups; giving them training and rules to abide by. But how many entities in Mexico really follow the rules on a regular basis? That's my main concern – yet another government-sanctioned organization being accused of human rights violations because they went on a power trip."

The spread of quasi-legal groups isn't limited to Mexico, by any means. Militia groups proliferated in Iraq under U.S. sponsorship, then in Afghanistan. There, the militias are seen by U.S. commanders as a means of improving security at the community level while freeing up troops for operations elsewhere. But there's a risk, with reports of U.S.-backed militias under the umbrella of the Afghan Local Police preying turning on – and preying on – the towns they were supposed to protect.

"There is inherent peril in vigilante groups cooperating with the security forces, especially in Mexico where the police and military are deeply infiltrated by criminal groups," wrote Marguerite Cawley, a research analyst with Latin America crime monitoring group InSight and the Colombian Attorney General's office. "In Colombia, legal paramilitary groups evolved into death squads, which often worked with the security forces to carry out the dirty work the legal agencies could not."

It's too soon to tell if the process will repeat itself south of the border, or if the questionable tactics of the militias will evolve into something worse. But there's always a danger when outsourcing the law to those who operate on its boundaries – let alone potentially training them.