Mexico's congress approved on Thursday a reform that lets some foreign agents carry arms inside the country, a significant change in a nation that has historically said the practice would violate its sovereignty.

Under the law, foreign customs and migration agents will be allowed to carry guns in previously established zones. Also, foreign leaders or heads of state will be able to enter Mexico with armed security details.

Officials say the presence of foreign agents in Mexico will speed up the joint inspection process and facilitate the flow of goods and people across borders. They also say foreign customs and migration agents at times need guns to guarantee their security given the problems of drug and human trafficking.

The bill, which was proposed by President Enrique Pena Nieto, was passed earlier by Mexico's Senate. On Thursday, the Chamber of Deputies approved it 288 votes to 82, with nine abstentions. It will now be sent to the executive branch to be published and go into effect.

Previously, Mexican law prohibited any foreign agent or official from carrying weapons inside the country or participating in operations to arrest criminals. Authorities have always denied media reports of U.S. agents directly taking part in anti-drug trafficking operations inside Mexico.

Permits will be limited to revolvers or semi-automatic pistols with a caliber less than .40 and be granted by Mexico's national defense department. The initiative demands reciprocity, implying that the foreign government would also allow Mexican agents to carry guns in its territory.