MEXICO CITY (Reuters) - Mexico and the United States said on Thursday they will open two jointly staffed border stations on Mexican soil in a bid to streamline trade and improve communication at the frontier, which has suffered due to tensions over migration.

U.S. Homeland Security Secretary Jeh Johnson and Mexican Finance Minister Luis Videgaray announced the program at a news conference in Mexico City, saying it would help speed up commerce at a congested border.

The pre-inspection stations will allow goods to be reviewed only once, instead of two separate times by U.S. and Mexican agents, they said. "I view pre-inspection with trusted partners like Mexico as the wave of the future," Johnson noted.

The plan has been under discussion for several years but was held up by a diplomatic flap over whether U.S. agents could carry guns in Mexico.

A shared facility has been operating since last year on the U.S. side of the border in Texas, at Laredo airport, allowing companies to ship goods into eight airports in Mexico, Johnson said.

Videgaray said a new facility to process agricultural goods from Mexico would be opened near the Otay Mesa crossing in Tijuana on the border with California.

Another joint facility will operate near the crossing at San Jeronimo in the Mexican state of Chihuahua, across the U.S. border from Santa Teresa, New Mexico, he said.

The San Jeronimo station will serve a nearby factory run by Taiwan's Foxconn Technology Group, the world's largest contract electronics manufacturer.

Mexico's Congress in April approved a change in the law to allow U.S. agents to carry arms in Mexico in certain places, removing a hurdle to the establishment of the centers.

Trade between the United States and Mexico has surged since the North American Free Trade Agreement two decades ago, but trade groups complain that investments in border infrastructure have lagged while congestion has increased, costing companies billions of dollars in business due to delayed shipments.

"This is a significant change in how the U.S. and Mexico work together," said Christopher Wilson, deputy director of the Woodrow Wilson Center's Mexico Institute.

"It's a step along the road to single border crossings. We could be there in a handful of years."