Australian Prime Minister Scott Morrison made a pre-Christmas visit to hundreds of troops in Iraq, telling them he wanted to say thank you from "one Australian to another."

But Morrison canceled a planned visit to Afghanistan on the advice of the defense force chief due to operational security reasons.

Morrison traveled to Iraq on Wednesday to meet special forces soldiers and other Australian military personnel who are training the Iraqi Army to combat the Islamic State group.

It was the conservative prime minister's first visit to the Middle East since he took the top job in August.

"I understand it's a sacrifice. I understand it's a big thing to be away from your family at this time of year," Morrison told troops at the Taji military complex north of Baghdad. "And that's why I've decided to come just to say 'thank you' from one Australian to another."

Morrison broke bread with hundreds of soldiers across Iraq from before dawn until after dark. He stressed that he would honor their contributions long after their active service ended.

He said that for many troops, it would be the first Christmas away from their families and friends, while others had endured the tyranny of distance before.

"On behalf of my family, to you and your families, I want to say thank you very much for your service," Morrison said. "But I also want to thank you as a prime minister, as the leader of the government, as a member of the Australian Parliament, on behalf of our entire nation."

There are currently about 800 Australian soldiers deployed in Iraq, including about 300 who are involved in Task Force Taji.

The rotating group has trained almost 40,000 Iraqi soldiers since its mission began in 2015. Its focus has gradually shifted from delivering front-line training to mentoring Iraqi security forces.

Capt. Steve Moye, who is beginning his first deployment, said he has noticed an immediate impact.

"Even just in the four weeks we've been here, the improvement in the individual skills of the Iraqi soldiers has been exponential," he said.

With a wife and two kids back home in Brisbane, Moye reshuffled birthday parties and opened Christmas presents early before he was deployed overseas. He said he wasn't sure how he would cope on Christmas Day.

Handshakes and small talk gave way to brass bands and a bilateral meeting when Morrison sat down with Iraqi Prime Minister Adel Abdul-Mahdi at his palace in Baghdad. Abdul-Mahdi stressed the need for ongoing security cooperation to liberate Iraq from the Islamic State group and on improving economic relations to drive investment and jobs.

"The stability of Iraq is the stability of the region, and the stability of the region would be stability for the whole world," he said.