NUEVA ITALIA, Mexico (Reuters) - Mexico's government on Monday pledged to take control of a violent western state after days of fighting between masked vigilantes and members of one of the country's most powerful drug cartels.

Since late last year, vigilante groups in the state of Michoacan have moved deeper into territory controlled by the Knights Templar cartel and they now are converging on Apatzingan, considered one of gang's main strongholds.

The vigilantes' advance has raised the risk of a bloody urban battle in Apatzingan. Interior Minister Miguel Angel Osorio Chong on Monday urged the vigilante groups to withdraw from the battleground so federal forces could take control.

"Be certain that we will contain the violence in Michoacan," Osorio Chong said at an event in the state capital of Morelia.

President Enrique Pena Nieto, who just ended his first year in office, has sought to shift the public focus away from grinding violence and onto a series of economic reforms he has pushed through a divided Congress.

But a steady stream of killings that plagued his predecessor's term continues, and the deepening crisis in Michoacan is beginning to cast doubt on his ability to maintain order. Drug trafficking gangs have been waging battles over trafficking routes for the last decade.

Analysts warned that any siege on Apatzingan by the vigilante groups could spark a much larger and more unpredictable urban conflict. They also said the government may have waited too long to try to contain the growing vigilante movement.

"This is a war. This is no longer an issue of public safety, or normal law enforcement. This is a political-military conflict between a number of armed groups," said security analyst Alejandro Hope of the Mexican Competitiveness Institute think tank. "This could get out of control any time now."

Masked vigilantes took power in more than a dozen rural communities in 2013 across Michoacan, claiming authorities were failing to stop rising extortion, kidnapping and violence.

Story continues

The government appeared to tolerate the so-called self-defense groups, apparently in the hope they could oust the Knights Templar and help restore order.

In the latest push by vigilantes, hundreds of men, many armed with high-powered rifles instead of the rusty shotguns toted by such groups elsewhere in the country, barreled into the town of Nueva Italia on Sunday in a convoy of pickup trucks, saying they wanted to liberate it from the Knights Templar cartel.

The vigilantes entering Nuevo Italia, located 22 miles from Apatzingan, were greeted by sporadic gunfire. At least one vigilante was wounded, according to a Reuters witness.

The group, mostly young men with faces covered by improvised masks made from t-shirts or bandannas, quickly moved into the town center and detained local police, who the vigilantes have said are working with drug traffickers.

FREE REIN

Both the state government and federal troops have stood aside as the vigilantes took over more and more communities.

Pena Nieto's top security officials have given mixed messages over the vigilantes. While they said the groups were breaking the law, they also said the groups had legitimate concerns.

The vigilantes' most visible leader, a doctor named Jose Mireles, was injured in an airplane accident just over a week ago. He was taken to a private hospital in Mexico City where he recovered under heavy guard by federal troops.

During their ascendance, the vigilante groups maintained their checkpoints and patrols at Michoacan and openly carried illegal weapons.

On Monday, Osorio Chong said federal forces would take over security in the zone around Apatzingan. He asked the vigilantes to put down their weapons and said laws against bearing arms would now be strictly enforced.

Some claim that the vigilantes are being backed by another cartel from neighboring Jalisco that is linked to the powerful Sinaloa cartel run by Mexico's most wanted man, Joaquin "Shorty" Guzman.

Previous bloody incursions by drug gangs into their rivals' territory have sparked scenes that look like low-intensity wars in places like the border cities of Juarez and Tijuana, or the business center of Monterrey.

But the government had not appeared to back an armed vigilante group in other recent conflicts in Mexico, Hope said.

Over the weekend, federal troops moved in greater numbers into Apatzingan, where there is a military base. Local residents

fear an incursion by vigilantes into Apatzingan could lead to heavy fighting.

Former President Felipe Calderon launched his military-led offensive against the drug gangs in Michoacan shortly after he took office in late 2006. But despite years of battles between federal troops and drug gangs that left around 70,000 people dead, security only deteriorated in Michoacan.

Michoacan's murder rate rose in 2013 compared to declines in most states, official data showed. Between January and November last year, 862 people were murdered in the state last year during the first 11 months compared to 755 in all of 2012, according to government data. Nationwide, murders peaked in 2011 amid Calderon's military-led challenge to the cartels.

Michoacan's murder rate has nearly doubled since 2006 as traffickers increasingly turned from marijuana plantations to producing methamphetamine in crude labs hidden in the state's mountains and avocado groves.

Late last year, dozens of mutilated corpses were found buried in mass graves in an area on the border between the states of Michoacan and Jalisco. Five decapitated bodies were dumped in the state capital in late December.

(Michael O'Boyle, Anahi Rama and Lizbeth Diaz in Mexico City; Editing by Simon Gardner)