Greek police said Wednesday they had rescued 50 migrants who had been held hostage in northern Greece, allegedly by two Pakistani men who were extorting their families for money.

Many of those rescued, who included five teenagers, were in bad physical condition, having been given minimal food and water. One man required hospitalization for pneumonia and dehydration.

The migrants — 38 Pakistanis, 10 Bangladeshis and two Sri Lankans — had been held in a complex of abandoned buildings east of the city of Thessaloniki, where most had been brought six days ago, although some were more recent arrivals. Authorities were alerted to their plight by relatives who received demands for money for them to be released.

Two Pakistani men were arrested on suspicion of kidnapping and blackmail, among other charges, and were to appear before a prosecutor later in the day to be formally charged.

The rescued men told police they had each paid between 1,500 and 3,000 euros ($1,780-$3,600) to be smuggled into Greece. But once they entered the country, the smugglers led them to the abandoned buildings, demanding another 2,000 euros or more for each for them to be released. The money was to be sent to the ring by relatives.

Thousands of migrants and refugees continue to arrive in Greece, hoping to eventually make it to other European countries. Most arrive either on Greek islands from the nearby Turkish coast, or cross the northern land border with Turkey.