The last direct flight carrying stranded Cuban migrants from Costa Rica has arrived in Mexico, ending an effort that transported 6,003 Cubans.

Nearly 8,000 Cuban migrant earlier had been stuck in Costa Rica after Nicaragua began refusing passage to them in November.

During the effort to transport the Cubans out, many were flown to Mexican border cities. Others traveled on buses, and then made their way to the U.S. border from southern Mexico.

Most of the Cubans have ultimately presented themselves at Mexican border crossings with the United States, where special policies for Cubans allow them to stay and enjoy other benefits.