A group of Sri Lankan migrant workers who paid $2,000 each to secure jobs in the Gulf were duped into travelling to Iraq, according to an aid agency.
Kurdish areas like Irbil have seen less violence than elsewhere in Iraq
They had their passports taken and were held against their will in the northern city of Irbil, the International Organisation of Migration (IOM) said.
The Tamil workers realised they were in Iraq because of the cold weather.
After a month they spotted a UN office and asked for help. The IOM helped fly them back to Sri Lanka on Monday.
The agency said the worsening security situation in Iraq had pushed up prices for migrant labour and encouraged trafficking and abuses by some recruitment agencies.
Millions of South Asians work abroad, mainly in the Gulf. Foreign remittances bring hundreds of millions of dollars into Sri Lanka's economy every year.
A statement from the IOM said the 17 migrants had all "signed contracts for jobs as domestic or textile workers after paying nearly $2,000 each to an employment agency".
It said the group had expected to work in Gulf countries but "they were flown to Irbil instead and kept in a house undergoing renovation where they were left by their Sri Lankan agent with another agent".
IOM spokeswoman Jemini Pandya confirmed to the BBC that all of the group were Tamils.
"They were flown out of Iraq to Jordan on Sunday and arrived back in the Sri Lankan capital, Colombo, on Monday," she said.
She said the workers had been through a traumatic experience and the IOM was doing its best to shield them from publicity.
According to the IOM statement, the migrant workers' appeals to be sent home were met with threats. They were kept imprisoned for a month with no heating, sanitation or proper accommodation.
It was only when they were being transferred from one location to another that they spotted the UN office and managed to contact officials there, who alerted the IOM.