The actor met families at the Debaga camp to discover how the conflicts in Iraq and Syria have affected the lives of children who have been forced to uproot their lives.
The father-of-four, 45, also spent time with displaced Iraqi families and Syrian refugees who are living in camps in the nearby Erbil area.
The ongoing unrest in Iraq and Syria has left tens of thousands of children separated from their families, forced into work at a young age, recruited into fighting or killed.
During his excursion, McGregor saw how Unicef is helping those fleeing IS-held city Mosul by giving them supplies of water and food as well as access to healthcare and child protection services.
He said that “the world is facing an unprecedented refugee crisis” as he pressed for more to be done to address the issue.
The Trainspotting star said: “Children uprooted by conflict can find themselves alone, without family and in grave danger.
“No child should be alone. Many of the children I’ve met in Iraq have been forced to flee their homes, risking their lives on dangerous journeys and have been exposed to unimaginable horrors.
“One girl I met, called Mirna, told me how her family slept in a disused, half-constructed shopping mall for over a year.
“The community donated food, clothes and supplies to her family and really came together to welcome displaced people.”
The Scottish actor said that “this act of humanity should be replicated everywhere, especially on our own doorsteps”.
He added: “It’s up to us to tell our friends, our neighbours and our governments that refugees are welcome.”
McGregor has been a Unicef Ambassador since 2004 and Peru, India, Nepal and the Congo are among the countries he has visited with the charity.
Around 3.6 million children in Iraq are at risk of being abducted and recruited into armed groups, and face the constant threats of death, injury and sexual violence.
September will see world leaders come together to discuss the global refugee crisis and Unicef is keen for a resolution to bring more help and protection to children forced to flee their homes.
Unicef UK is also calling on the UK Government to take urgent action to reunite unaccompanied refugee children with their families.