Forty-six Turkish hostages seized by fighters of the Islamic State in Iraq and the Levant in the northern Iraqi city of Mosul in June have been brought safely back to Turkey by the country's intelligence agency, according to Ahmet Davutoglu, Turkey's prime minister.

The Turkish hostages, including diplomats, soldiers and children, were seized from Turkey's consulate in June, along with three Iraqis, who were also released.

Live Box 201461213304888167

Davutoglu said on Saturday the freed hostages were being brought to the southern Turkish city of Sanliurfa and that he would travel back from Azerbaijan, where he is on an official visit, to meet them.

"Today at 5am we brought our citizens who were detained in Iraq to our country. From my heart, I thank the families who maintained their dignity," Davutoglu said on his Twitter account.

He did not provide details on the circumstances of their release but said the hostages were freed through the Turkish intelligence agency's "own methods" and that no operation was carried out.

The seizure of the hostages had left Turkey, a member of the NATO military alliance and a key US ally in the Middle East, hamstrung in its response to the threat from ISIL fighters over its southern borders in Iraq and Syria.

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

The group has beheaded two US journalists and a British aid worker who were working in Syria as payback for air strikes that the US has launched against them in Iraq.

"I am sharing joyful news which as a nation we have been waiting for," Davutoglu said.

"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.

"They have crossed into Turkey and I am on my way to see them."

Separately, 32 Turkish lorry drivers who were also seized in Mosul in June 6 were released a month later.

Turkey did not provide information surrounding their release.

Source: Al Jazeera and agencies