"Every person has the right to the future," Francis said, at one point looking at those children.
The pontiff, entering the seventh year of his papacy, has become an outlying voice advocating that migrants be welcomed with open arms - a stance that is rare now among political leaders across the West.
But the message was particularly resonant in Morocco, which last year became the primary passageway for migrants trying to reach Europe after the European Union and the hardline Italian Government worked to close off other routes across the Mediterranean.
Moroccan officials have indicated that smuggling networks have shifted, too.
Migration numbers to Europe are down drastically from the peak in 2015. But individual countries still feel pressure. Morocco has faced criticism from humanitarian groups for allegedly rounding up undocumented migrants and transferring them to remote parts of the country.
Spain has faced its own dilemmas: Anti-migration sentiment is on the rise ahead of April 28 general elections. And authorities in Barcelona in January prohibited a humanitarian ship from leaving port for a migrant rescue mission in the Mediterranean.
Francis, in a recently conducted interview with a Spanish journalist, called it an "injustice" that the Open Arms boat had been prevented from operation. Other governments across Europe have taken steps of their own to curtail the work of NGO rescue vessels.
"Why do they do it?" Francis asked. "To drown them?"
Francis has repeatedly placed migration at the centre of his papacy. In 2016, after a visit to the Greek island of Lesbos, he ushered 12 Syrian refugees back to Rome aboard the papal plane.
But his remarks today took a broader aim, as Francis described his philosophies on migrants: how they can be exploited; how they should be encouraged to learn the local language; how migrants can only integrate with the absence of "fear and ignorance."
"We know that it is not easy - for those who arrive and for those who receive them," Francis said.
The 27-hour trip is Francis' latest outreach to the Muslim world, following visits to Egypt in 2017 and the United Arab Emirates last month.
Francis described Morocco as a "natural bridge between Africa and Europe," and he was greeted at the airport by King Mohammed VI. The two leaders took separate vehicles - the popemobile and a Mercedes limousine - to a never-completed 12th century mosque, where Francis spoke about improving "mutual understanding" between Christians and Muslims.
"It is likewise essential that fanaticism and extremism be countered by solidarity on the part of all believers," said the Pope, who later in the day visited an institute that trains imams and also offers programmes for women.
In an joint declaration, Francis and King Mohammed VI made an appeal for another area that has been a hotbed of tensions, calling on Jerusalem to be preserved as a "symbol of peaceful coexistence."