The video, uploaded on YouTube, drew the attention of an expatriate Bangladeshi official there, prompting action which eventually led to the freedom for the labourers.
The band of workers flew back to Dhaka on a Fly Dubai jet, which touched down at Shahjalal International Airport at 10am Friday.
Arriving in Dhaka after months of enduring starvation and mistreatment, Kurigram's Ratan Mia said, "I can now breathe freely, return to my family. We were imprisoned for so many days, but now we are free."
He said the group went to Afghanistan on Oct 10 last year to work at Folad Steel Mill.
Each of them was contracted on a $500 monthly salary. The authorities had also promised them an extension of their visas.
"(But) our employer paid 300 dollars for two months before cutting off pay. We were forced to stay in the factory after our visas expired. With the mill guarded, we had no way to get out," said Manikganj's Ripon Ali.
Tangail's Sohel Mia described the shocking circumstances they had gone through on the foreign soil.
"We survived on unhealthy food for several months, like gram and low-grade bread. The factory could not run well as the owners never turned up. Attempts to communicate with them also failed," he said.
A Bangladeshi business executive there, Golam Azam, along with several others, took notice of the video which soon went viral on the social media.
"After watching the video, all of us thought we had to help our Bangladeshi brothers. Then we contacted different government offices," Azam told bdnews24.com after accompanying the labourers home.
"The International Organization for Migration came forward to assist them. They approached their Bangladesh segment and eventually the news reached our foreign ministry."
IOM's National Program Officer for Bangladesh Mohammad Shakil Mansoor said the organisation took steps after getting the details.
He said the 'extremely positive stand' taken by Bangladesh's foreign and home ministries, and other related government departments, was decisive in ending the workers' plight.