Four suspected ISIS jihadists were arrested in Nicaragua early this week after they entered the country illegally via Panama and Costa Rica.

The United States government issued a warning on Monday after three men with ties to ISIS were believed to be in the Central American state amid fears they were heading to the US border.

U.S. authorities believed the group intended to sneak into Mexico.

They were arrested on Tuesday morning along with a fourth man.

Egyptian nationals Mohamed Ibrahim, 33, and Mahmoud Samy Eissa 26, along with Iraqis Ahmed Ghanim Mohamed Al Jubury, 41 and Mustafa Ali Mohamed Yaoob, 29, were all detained in Cardenas, a city in the state of Rivas.

The suspected jihadists crossed through an uninhabited passage known as La Guasimada located between Costa Rica and Nicaragua, according to Nicaraguan outlet La Nacion.

Ahmed Ghanim Mohamed Al Jubury (left), Mohamed Ibrahim (center) and Mahmoud Samy Eissa (right) appeared in a warning released by the United States on Monday

They were turned over to Costa Rican authorities on Tuesday night and were transferred to a detention center in Los Lagos de Heredia.

Officials in Costa Rica are currently investigating the men and will likely deport them to their respective countries.

Ibrahim, Al Jubury and Yaoob were first detected by Panama's immigration system on May 12 and spent nearly a month there before arriving in Costa Rica. It's unknown when and how they entered Panama.

The four men arrested by Nicaragua's military on Tuesday allegedly had plans of traveling towards Mexico with the intent of sneaking into the United States

The Costa Rican security ministry was made aware of the three men's presence in the country on June 9.

Yaoob was detected in Costa Rica on June 13.

However, the police consulted its database and found that the men did not pose any danger.

'We were alerted in the middle of June with details that profiled them as dangerous. The Migration Police followed security protocol and we passed the information along to the American Embassy and the information was ruled out,' said Steven Madden, director of the Migration Police, according Costa Rican outlet La Prensa Libre.

Costa Rican President Carlos Alvarado backed the assessment of his immigration officials and said that the intelligence provided by the U.S. was thoroughly checked.