Vigilantes perform a gun salute during the funeral of Manolo Mora, the son of vigilante leader Hipólito Mora, who was killed in a shootout between rival vigilantes, in the town of La Ruana in Mexico's Michoacan state on Dec. 18. (Alan Ortega/Reuters)

MEXICO CITY — What began as a scrappy band of Mexican farmers rising up against a brutal drug cartel in the western state of Michoacan has devolved into a confusing mess of factions fighting each other and the government.

The latest sign of trouble in Michoacan came early Tuesday, when shootouts erupted between Mexican soldiers and local gunmen, leaving at least nine people dead in the town of Apatzingan.

Even before this week’s violence, the farmers' movement had been consumed by power struggles. One of the founders of the militia the farmers formed, Hipólito Mora, is now in jail and accused of murder for his involvement in a gun battle in mid-December between his followers and those of another militia commander, Luis Antonio Torres, that killed 11 people, including Mora’s son. The charismatic face of the movement, a lanky surgeon named José Manuel Mireles, has been imprisoned for months for illegal possession of weapons.

When the uprising started in February 2013, the government relied on the militiamen to do much of the fighting against the Knights Templar cartel, which had been killing and extorting residents across the Michoacan lowlands known as the Tierra Caliente. Even after more Mexican troops and federal police were deployed there, they could often be seen standing around or manning checkpoints, while the militiamen rounded up cartel suspects.

Faced with a large — and, in some areas, popular — group of untrained armed civilians, the Mexican government proposed converting them into official “rural police.” Last May, the government began demobilizing the militias, as people turned out by the hundreds to register their weapons. But the new police force has failed to pacify the area, and the government’s point man for the Michoacan crisis, Alfredo Castillo, said on the radio this week that the force may be temporary.

Even as other crises have taken precedence — such as the disappearance of 43 teachers’ college students in September in neighboring Guerrero state — tensions and violence in Michoacan have continued. Throughout this period, the militia movement has disintegrated into warring factions, with rival commanders accusing each other of colluding with drug cartels and sometimes openly fighting. New gunmen have emerged ascendant, particularly a group known as the “Viagras,” which was behind the takeover of the Apatzingan city hall over the past two weeks, according to Mexican news accounts.

The most recent confrontation began early morning Tuesday as Mexican soldiers and federal police attempted to dislodge those who had seized city hall. The occupation of government buildings has spread in recent months, partly in protest of the government’s role in the case of the missing students of Guerrero. In the case of Apatzingan, the demands of the group were unclear.

Castillo said there were two confrontations: the first when soldiers and police tried to dislodge the gunmen from the city hall, and the second as they moved away with more than 20 seized vehicles. Various accounts said nine to 11 people died, two police officers were injured and 44 people were arrested. The newspaper Reforma cited an anonymous witness as saying that at least three who died were shot execution-style by police after they had surrendered.

On the same day as the violence, Mexican President Enrique Peña Nieto was meeting with President Obama in Washington. Drug-related violence and other scandals have sapped Peña Nieto's popularity in recent months. Mexican authorities also found 10 bodies and 11 severed heads Tuesday in graves in Guerrero, the Associated Press reported.

Obama said the United States was committed to being a “friend and supporter of Mexico in its efforts to eliminate the scourge of violence and the drug cartels that are responsible for so much tragedy inside of Mexico.”