SAN JOSE (Reuters) - Thousands of African, Haitian and Asian migrants bound for the United States have amassed in immigration shelters in Panama and Costa Rica as plans to relocate them to less crowded areas to lower the risk of spreading the coronavirus have faltered.

Earlier this week, Costa Rica’s government said it had begun transferring about 2,600 migrants headed for the United States from its southern border with Panama to its frontier with Nicaragua, citing concerns that large crowds could further spread the virus.

However, the head of Costa Rica’s immigration office, Raquel Vargas, told Reuters on Saturday that the transfer was suspended until further notice.

“We must find a solution,” Vargas said after Nicaragua decided to send its military to its southern border.

Vargas said the transfer of the first group of migrants in coordination with Panama was “very successful,” but that under the current circumstances more people could not be moved.

Costa Rica has reported 295 confirmed coronavirus cases and two deaths so far, and has taken stringent measures to curb the spread of the virus. Panama is the Central American nation with the most cases, with 901 confirmed infections and 17 deaths.

By Saturday, most of the migrants were in the Panamanian provinces of Darien and Chiriqui, Vargas said. Another 377 remained on Costa Rican soil, mostly in the southern city of Golfito and some in a government shelter in La Cruz, next to Nicaragua.

In recent years, migrants who are not from Latin America have entered Costa Rica from Panama in a controlled and coordinated manner following a migration agreement signed between the two countries four years ago.

Most Central American nations have closed their borders to prevent the spread of coronavirus, and over the past year Mexico has forbidden large groups of U.S.-bound migrants to enter the country in the face of U.S. demands to curb the flow of migrants across the Mexican-U.S. border.