Turkish intelligence agents brought 46 hostages seized by Islamic State militants in northern Iraq back to Turkey yesterday.

They had spent more than three months in captivity and were rescued in what Turkish president Tayyip Erdogan described as a covert operation.

Security sources said the 46 were freed overnight in the town of Tel Abyad on the Syrian side of the border with Turkey after being transferred from the eastern Syrian city of Raqqa, Islamic State's stronghold.

Officials declined to give details of the rescue operation.

The hostages, who included Turkey's consul-general, diplomats' children and special forces soldiers, were seized from the Turkish consulate in Mosul on June 11 during a lightning advance by the insurgents.

Family members rushed to the steps of the plane which brought the freed captives, to the Turkish capital Ankara from the southern city of Sanliurfa, where they had earlier been welcomed by prime pinister Ahmet Davutoglu.

Groups of supporters waved Turkish flags as Davutoglu hugged the consul-general and members of the diplomats' families before addressing the crowd from the roof of a bus, saying the authorities had worked tirelessly for the hostages' release.

"I thank the prime minister and his colleagues for the pre-planned, carefully calculated and secretly conducted operation throughout the night," Erdogan said in a statement.

"MIT [the Turkish intelligence agency] has followed the situation very sensitively and patiently since the beginning and, as a result, conducted a successful rescue."

Speaking to reporters earlier in Azerbaijan before cutting short an official visit, Davutoglu declined to give details on the circumstances of the hostages' release, saying only that it was carried out "through MIT's own methods".

Turkish officials had repeatedly said efforts were underway to secure their freedom and that the hostages were in good health, but had declined to comment further.

Three non-Turkish civilians taken in the same attack were released in the operation yesterday, a foreign ministry official said.

Independent broadcaster NTV said Turkey did not pay a ransom and that no other country was involved. There were no clashes with Islamic State militants during the operation, it said.

Without naming its sources, it said MIT tracked the hostages as they were moved to eight different sites during 101 days in captivity.

Their capture left Turkey, a member of the NATO military alliance and a key US ally in the Middle East, hamstrung in its response to the insurgents, who have carved out a self-proclaimed caliphate in parts of eastern Syria and western Iraq, just over the Turkish border.

The rapid and brutal advance of Islamic State, bent on establishing a hub of jihadism in the centre of the Arab world on Turkey's southern fringe, has alarmed Ankara and its Western allies, forcing them to step up intelligence sharing and tighten security co-operation.

Turkish deputy prime minister Numan Kurtulmus said yesterday tens of thousands of Syrian Kurds had crossed into Turkey over the past day after Islamic State seized dozens of villages near the border.

The United States is drawing up plans for military action in Syria against Islamic State fighters, but Turkey made clear it did not want to take a frontline role, partly because of fears for the fate of the hostages.

The militants have beheaded two US journalists and one British aid worker, using the tactic to put pressure on Western governments after US air strikes helped halt Islamic State's advances.