Mexico’s Congress has voted in favour of extending the presence of the military on the streets until 2028.
Troops have been carrying out public security duties for years as part of Mexico’s war against drugs and the gangs which control their trade.
But critics say extending the military’s duties for another four years further militarises the country.
Rights groups say the militarisation of police duties has led to human rights abuses and further violence.
But members of the president’s party argued that if the army were to be taken off the streets, Mexico’s population would be left at the mercy of organised crime gangs.
The bill was passed after a marathon session in the Chamber of Deputies with 339 votes in favour and 155 against.
It will still have to be passed by the legislatures of 31 states and the capital, Mexico City, to come into law, but the big hurdle was getting it approved in Congress.
The move has the backing of President Andrés Manuel López Obrador.
Before coming to office, Mr López Obrador was an opponent of having troops on the streets, and he campaigned on a promise to return them to their barracks.
Once in office, he created a new civilian-led force, the Guardia Nacional (National Guard), to replace the federal police and to boost security in areas wracked by cartel violence.
But he then pushed for the National Guard to come under the control of the army, a move which was approved by Congress last month.
The president argued that having the 115,000-strong force under the control of the military would prevent corruption.
However, the United Nations called it a “setback to public security grounded in human rights”, arguing there would be no civilian oversight of the National Guard.
Members of Congress who voted against both bills accuse the president of giving the military, which has been accused of widespread abuses, more power.
Accusations of human rights abuses by the military hit the headlines again last month when a retired general and two other members of the army were arrested over their alleged links to the disappearance of 43 students in 2014.
President López Obrador has remained defiant in the face of the criticism, insisting his plan “isn’t to militarise or move towards authoritarianism, but to guide – under the defence ministry’s oversight – the healthy growth of what should be the main public security institution in the country”.