Federal police in Mexico's Riviera Maya resort area freed 31 Cubans being held by gunmen in a house, authorities said.
The Cuban migrants said masked gunmen held them in the home near the Caribbean coast demanding money the Cubans did not have.
Police received multiple reports on the situation before moving in to free the 22 Cuban men and nine Cuban women, said Mexico's National Public Safety Board.
The Cubans, who did not have Mexican residency, were taken by state authorities for health checks.
At the beginning of the year former US president Barack Obama ended a longtime US policy of allowing Cubans who reach US soil to get near automatic US residency, work and health benefits.
Since then, hundreds of Cubans who left their country for US shores have become stuck in several Latin American countries including Ecuador, Colombia, Panama, Costa Rica and Mexico.
Central America -- particularly its violence-prone nations of Guatemala, El Salvador and Honduras -- are a main source of undocumented migrants to the United States. The region is also a transit point for migrants from elsewhere.
Mexico provides more than half the migrants to the United States, though fewer than in years past, and is the country that shares America's southern border.
US President Donald Trump says the undocumented immigrants "present a significant threat to national security and public safety," and has pledged to build a wall along the US-Mexican border.