After more than three months stranded in Costa Rica, 180 of the 8,000 Cuban migrants trapped here finally began their long-awaited trip north, toward the U.S. border.

The first pilot flight took off from Costa Rica's Daniel Oduber airport in the northern city of Liberia late Tuesday night as part of a regional agreement to overcome Nicaragua's refusal to let them through by land.

Nicaragua's leftist government closed the border to Cubans on Nov. 13. Most Cubans came to Panama and Costa Rica via a well-worn air bridge through Ecuador, before that South American country began demanding visas for Cubans in December.

There has been an exodus of migrants from Cuba in recent months after the communist-run country loosened requirements for leaving. Many potential migrants in Cuba are also worried that the re-establishment of relations between the United States and Raul Castro's government could end special treatment that allows them to stay in the United States once they arrive there.

The first flight carried 180 migrants from Costa Rica to El Salvador; from there they will travel by land through Guatemala to the Mexican border. It is not clear how they will move through Mexico.

Six of the lucky ones selected for the first flight were staying at a shelter at the La Cruz bilingual school, about 12 miles (20 kilometers) from Costa Rica's border with Nicaragua.

Lislenia Fernandez is one of them. She arrived in Costa Rica from Panama on Nov. 8 with her husband Yordani Casanova, but because she had to wait at that border for a transit visa, she didn't get to the border with Nicaragua until it was too late.

"They told me four days ago and I still don't believe it, I didn't expect to be in the first group," said Fernandez. "I'm happy because I can travel with my husband."

Fernandez hopes to get to Miami, where her brother-in-law is, but she had to leave behind her sons aged 4 and 8. "We are going to look for a way to bring them over."

Arnobis Tellez left behind three children and a grandchild in Cuba. He was also selected for the first flight, but still must make the uncertain and dangerous crossing through Mexico. He says he doesn't know how he will do it.

"These last months have been terrifying, because nobody thought this was going to happen," Tellez said. "We thought that by this time we would all be in the United States."

In Cuba, the migrants' families were also waiting for word of the first group to fly out.

The family of Randy Salabarria, 40, waits to get word of when he will leave Costa Rica.

"He calls me and tells not to worry. He says he is well and wants to go to the United States," said his mother, Miriam Crespo, in the Cuban town of Bahia Honda.