Forty-nine Turkish hostages who had been held for months in Iraq by ISIS militants were returned to Turkey on Saturday after what Turkey said was a covert operation led by its intelligence agency.

The hostages, including diplomats and their families, had been seized in June from the Turkish consulate in the Iraqi city of Mosul.

?The Turkish intelligence agency has followed the situation very sensitively and patiently since the beginning and, as a result, conducted a successful rescue operation,? President Recep Tayyip Erdogan said in a statement Saturday.

The details of the hostages? release were unclear. The semi-official Turkish news agency Anadolu reported that Turkey had not paid ransom for them or engaged in a military operation, but that it had used drones to track the hostages, who had been moved to different locations at least eight times during their 101 days in captivity.

The agency said Turkish intelligence teams had tried five times to rescue the hostages, but that each attempt had been thwarted by clashes in the area where they were being held.

?I am sharing joyful news, which as a nation we have been waiting for,? Prime Minister Ahmet Davutoglu said in Baku, Azerbaijan, where he was on an official visit. ?After intense efforts that lasted days and weeks, in the early hours, our citizens were handed over to us and we brought them back to our country,? he said.

The prime minister left Baku for the Turkish province of Urfa, where the freed hostages, who included Consul General Ozturk Yilmaz, other diplomats, children and consulate guards, had been brought from Raqqa, the de facto headquarters of the ISIS militants.

One hostage, who was not identified publicly, told a Turkish reporter for CNN aboard the flight to Urfa, that the hostage shad been moved eight times. ?We had tough days, very bad days,? he said.

Another hostage, asked whether he and the others seized had been tortured, said, ?Surely, we went through certain things.?

The freed hostages were later to be flown to Ankara to be reunited with their families. They were advised not to immediately talk to the news media.