The man was wrestled to the ground by security officials metres away from an open-top car carrying King Mohammed VI
An unidentified man broke through security lines in an effort to reach a motorcade carrying Pope Francis and Morocco's King Mohamed VI.
Live television pictures showed the man was restrained by security officials moments before he reached an open-top car carrying the king.
The pontiff was travelling in a different vehicle at the time.
The incident in Rabat happened shortly after he landed at the start of a two-day trip that officials say will focus on inter-faith relations.
King Mohamed waiting in the heavy rain to greet the pope on the tarmac for what is the first papal visit to Morocco since 1985.
The two were then carried in a large motorcade as part of a street parade in the capital Rabat to an official welcoming ceremony.
Focus on migration and interfaith dialogue
"The issue of migration will never be resolved by raising barriers, fomenting fear of others or denying assistance to those who legitimately aspire to a better life for themselves and their families," Francis said at the welcoming ceremony.
Morocco has become a key departure point for African migrants trying to reach Europe after crackdowns that closed or limited routes elsewhere.
Italy's anti-immigrant interior minister has closed ports to rescue ships run by charity groups.
Francis, who has made defence of migrants and refugees a key part of his preaching, said he was concerned about their "frequently grim fate" and receiving countries must acknowledge that migrants were forced to leave their homes because of poverty and political upheaval.
Francis, making the first papal visit to Morocco in 34 years, also praised King Mohamed for providing "sound training to combat all forms of extremism, which so often lead to violence and terrorism, and which, in any event, constitute an offence against religion and against God himself".