MEXICO CITY — Mexico's president said Friday he is putting the army in charge of customs at border crossings and seaports to combat corruption and the massive smuggling of drugs and precursor chemicals.

President Andrés Manuel López Obrador made the announcement during a visit to the Pacific coast port of Manzanillo, where some of the biggest multi-ton shipments of drug and illicit chemicals have been seized over the last decade.

It was the latest in a series of new roles that López Obrador has entrusted to the nation's armed forces, which are now involved in everything from construction of government projects to running tree nurseries.

The president said the trafficking through the port accounted for a lot of the violence in the state of Colima, where Manzanillo is located. Colima has the highest per-capita homicide rate in Mexico, in part because drug cartels are believed to be fighting for control of ports and shipments coming through them.

"We have taken this decision about management of the port, because of the mismanagement, the poor administration of the seaports, the corruption, the smuggling of drugs into the country through these ports," López Obrador said. "This explains to a large extent why there are attacks and homicides in Colima."

The army and the National Guard, which is mainly staffed with army members, are guarding hospitals and transporting medical supplies for the pandemic, have been given an extended mandate to perform civilian policing roles and are running bulldozers to build a new airport outside Mexico City.

The army is also building thousands of new branch offices for a government-run bank. The Navy has been given control of all port captaincies and is in charge of removing sargasso seaweed choking some beaches at resorts on the Caribbean coast.

Most shipments of the synthetic opioid fentanyl, and precursor chemicals used to make it, are believed to come from Asia through Pacific coast ports like Manzanillo or Lazaro Cardenas, to the south. Cartels use the same route to import chemicals used to make methamphetamines, often on an industrial scale.

In 2010, the Tax Administration Service, which was previously in charge of customs, seized a then-record 200 metric tons of meth precursors at the Manzanillo port.

It would not be the first time the Mexican government has turned to the armed forces to try to solve the thorny problem of corruption and cartel domination at seaports.

In 2013, the government put the Navy in charge of the Lazaro Cardenas seaport of the neighboring state of Michoacan after the Knights Templar drug cartel reached such astonishing levels of control that it was found to be operating bulk freight yards and participating in the iron ore trade at the port.

Mexico has also had a decades-long history of struggling with corrupt customs inspectors. In 1991, Mexico fired nearly all 3,000 of its customs inspectors without warning, replacing them with younger, better-educated personnel in an effort to combat corruption and improve efficiency.

It was unclear whether the tax administration service would remain in charge of customs services at airports. But in any case, many of the inspections at airports and land border crossings — where most illicit weapons are smuggled — are already carried out by the military.