Burhan Ozbilici, Associated Press
Turkey's new Prime Minister Ahmet Davutoglu announces his cabinet ministers in Ankara, Turkey, in this Aug. 29, 2014 file photo.

ANKARA, Turkey — Turkish Prime Minister Ahmet Davutoglu said Saturday that 49 Turkish hostages who were seized by Islamic militants in Iraq have been freed and safely returned to Turkey, ending Turkey's most serious hostage crisis.

The Turks, including diplomatic staff, were seized from the consulate on June 11, when the Islamic State group overran Mosul, Iraq and stormed the Turkish Consulate there. The hostages included Consul General Ozturk Yilmaz, other diplomats, children and special forces police.

Davutoglu told Turkish reporters during a visit to Baku, Azerbaijan that the hostages were released early on Saturday and had arrived in Turkey. He was cutting his visit short to meet with the hostages in the province of Sanliurfa, near Turkey's border with Syria.

He did not provide details on the circumstances of their release but said the hostages were freed through the intelligence agency's "own methods" and that no operation was carried out. He thanked Turkey's intelligence agency and the Foreign Ministry's head official for their efforts toward their release.

Turkey had publicly resisted joining a coalition to defeat the Islamic State group, citing its 49 kidnapped citizens.

The United States had been careful not to push Turkey too hard as it tried to free the hostages.

The extremist group has beheaded two U.S. journalists and a British aid worker who were working in Syria as payback for airstrikes that Washington has launched against them in Iraq.

"I am sharing a 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," Davutoglu said.

Thirty-two Turkish truck drivers who were also seized in Mosul in June 6 were released a month later. Turkey did not provide information surrounding their release.