The Turkish authorities struck an agreement with the hijackers to release women and children on board through the front of the aircraft.
However, while they were being let out, most of the remaining passengers managed to break down the back door of the aircraft and jump out.
There were several reports that the two men were Iranians.
But Osman Gunes, the Turkish interior minister, said the men were of Turkish and Syrian nationality.
Gunes said: “One of them, Mehmet Resat Ozlu, is a citizen of the Turkish Republic. The other… holds a Syrian passport, but is probably a person of Palestinian origin.
“We persuaded them to surrender themselves. They are currently being questioned by police.”
He said the authorities were continuing to examine their ID documents.
The CNN-Turk news channel had shown two people leaving the plane and being handcuffed before being taken away in a white vehicle.
A crew member, quoted by Turkey’s private NTV news channel, said:
“The hijackers regret what they did and want to return to Iran.”
Yousef al-Sharif, Al Jazeera’s correspondent in Ankara, Turkey’s capital, said: “The passengers who escaped said that the kidnappers had claimed they were from al-Qaeda and were protesting against US foreign policy. They were demanding to be flown to a Middle East country.”