The men, who were studying at a religious school in Pakistan, were trying to catch a Thai Airways flight on June 8 when they were intercepted.
Thailand’s government said an investigation into the students found the men had no links to the Islamic State militant group or any criminal organisation.
“The five Thai students were released from Pakistan and travelled back to Thailand this morning,” Sek Wannamethee, a spokesman for Thailand’s foreign ministry, told Reuters.
The students were released by Pakistani authorities on Monday, he said. He gave no details about negotiations to free the men but added that the case against them would be handled by Thai embassy staff in Pakistan.
“In terms of the case, it has not finished yet. Thai embassy officials will continue to work on this case until it is over.”