STORY UPDATED: March, 20, 2020  12:23 PM

SAN DIEGO (CBSDFW.COM/AP) — As expected, the United States and Mexico announced Friday that travel would be sharply restricted along their shared border as part of efforts to control the spread of the coronavirus.

U.S. officials and those in Canada and Mexico also agreed that everyone who tries to illegally cross a border would be immediately returned to their native country, with officials citing the potential health risk of detaining people from all over the world.

President Donald Trump and Mexican Foreign Secretary Marcelo Ebrard said the two governments agreed to prohibit recreational and tourist travel, similar to the restrictions put in place earlier this week along the U.S.-Canadian border.

Trump said the actions with the country’s North American partners “will save countless lives.”

Secretary of State Mike Pompeo said the new border restrictions would take effect at midnight Friday and remain in place as long as needed.

There would be no ban on people traveling between the U.S. and Mexico for work or other essential activities and there would be no halt to commercial traffic, Ebrard said.

“Everyone else is not expected to have any difficulties,” he said. “We’re not talking about closing it.”

By excluding commercial traffic from the ban, the two governments substantially softened the economic effects. Fewer Americans are also heading south because of a statewide stay-at-home order in California and a State Department warning advising Americans not to travel abroad.

Still, the restrictions are a major development along the world’s most heavily crossed border.

Acting U.S. Homeland Security Secretary Chad Wolf told reporters at the White House that the restrictions were aimed at eliminating non-essential travel across that border.

“We want to make sure that cargo continues, trade continues, heath care workers continue to be able to traverse that border. But tourism, some recreational activities and other things needs to stop during this crisis,” he said.

U.S. officials have in recent days described plans to immediately turn back to Mexico anyone who crosses the border illegally, including asylum-seekers, under a law aimed at curbing the spread of communicable diseases.

The measure announced Friday would cover migrants crossing illegally into the United States as well as into Canada, where some people have fled to escape U.S. enforcement efforts. Ebrard said Mexico would only accept the return of migrants from Central America and Mexico.

U.S. Customs and Border Protection officials briefed business leaders Thursday on the plans to prohibit non-essential travel with Mexico, said Paola Avila, chair of the Border Trade Alliance, a business group.

U.S. officials provided a long list of “essential” workers that would be unaffected going to and from their jobs, including farm workers, restaurant and grocery store employees and bus drivers, said Avila. Mexico was preparing similar restrictions on visitors from the United States.

Keeping trade flowing, as the U.S. and Canada agreed to do, contains the economic damage. Mexico is the U.S.’s largest trading partner, just ahead of Canada. The U.S. accounts for about 75% of Mexican exports, including autos, computers and medical devices.

While halting travel for students, shoppers, families and many workers would be a major blow to border economies, the impact has already been felt.

The State Department on Thursday issued a new travel alert urging Americans not to go abroad under any circumstances and to return home if they are already abroad unless they plan to remain overseas.

(© Copyright 2020 CBS Broadcasting Inc. All Rights Reserved. The Associated Press contributed to this report.)