Mexico's Senate has approved a law that would give the military legal justification to act as police, despite objections from human rights groups.

The law allows the military to intervene when the president determines there is a threat to national security and adds a requirement that states draw up a plan to improve corrupt or inefficient police forces.

Many of Mexico's 31 states rely on soldiers and marines to battle well-armed drug cartels, but rights groups say that eases pressure on local governments to train and recruit competent, honest law enforcement.

The senate also approved a change which says military forces cannot be used to control political protests.

The altered bill approved Friday now returns to the lower house for final passage.