Plagued by mosquitoes at night and marauding monkeys by day, ship captain Glenn Madoginog was held for months at an Indonesian naval base before ending up in a cramped prison cell, sleeping alongside convicted murderers and child rapists.

The Filipino father of four was one of dozens of captains held at the Batam naval base after being arrested for anchoring in Indonesian waters without a permit while waiting to enter Singapore, according to a dozen people involved in the cases, including captains, ship owners, intermediaries and insurers.

Most of the captains were freed after a few weeks once ship owners made unofficial payments to navy intermediaries of between $300,000 and $400,000, the people said.