By Agence France-Presse
His visit, coming after the Islamic State group (IS) killed dozens of worshippers in church bombings earlier this month, gave the country's beleaguered Christian community an occasion to be joyful.
"The only fanaticism believers can have is that of charity. Any other fanaticism does not come from God," the pope said at a mass for Egypt's Catholics.
"True faith... moves our heart to love everyone... It makes us see the other not as an enemy to be overcome but a brother and sister to be loved," he told a crowd of about 15,000 pilgrims.
The mass came on the second and last day of a visit which saw him plead for tolerance and peace on Friday at a Coptic church bombed by IS in December.
The jihadists have threatened further attacks after the Cairo attack that killed 29 people and suicide blasts in the cities of Tanta and Alexandria north of the capital earlier this month that killed 45.
The spiritual leader of the world's almost 1.3 billion Catholics also became the first pope to visit the headquarters of the grand imam of Al-Azhar, Ahmed al-Tayeb, one of the Muslim world's leading religious authorities.
On Friday, Francis met Coptic Orthodox patriarch Pope Tawadros II, and both attended an emotional service at the Saint Peter and Saint Paul church attacked in December.
They prayed at a makeshift shrine for its victims, who were mostly women.
They also signed a joint declaration pledging to "strive for serenity and concord through a peaceful co-existence of Christians and Muslims".
On Saturday, the crowd cheered and released yellow and white balloons as Francis lapped the Cairo stadium in a golf cart, waving to onlookers as a chorus sang a joyous hymn.
Worshippers old and young, nuns and priests, had been bused in under tight security with Egypt under a state of emergency following the church bombings.
It was, said Coptic Catholic engineer Maged Francis, a "historic occasion".
"It's unlikely it will ever happen again," he said. "Today joy has eclipsed the sadness of the last few weeks."
The stadium chosen for Saturday's mass is on Cairo's outskirts and easier to secure, but in 2015 it saw clashes between football fans and a stampede that killed 19 people.
After the mass, the pope travelled to a seminary in the city where he urged his audience to promote dialogue.
President Abdel Fattah al-Sisi later escorted the pontiff to his aircraft at Cairo airport before he departed.
In a speech attended by Sisi on Friday, the pope called for "unconditional respect" for human rights.
Sisi has been criticised internationally for human rights abuses since he led the military overthrow of his Islamist predecessor Mohamed Morsi in 2013.
Heavy security surrounded the pope's tightly scheduled trip as he travelled from one engagement to another in a closed car.
'Peace is holy'
On Friday, the 80-year-old pontiff denounced violence and "demagogic" populism in an address to a Muslim-Christian conference.
"Peace alone... is holy and no act of violence can be perpetrated in the name of God, for it would profane his name," Francis said.
He criticised what he called "demagogic forms of populism... on the rise", saying they were unhelpful to peace.
Christians, who make up around 10 percent of Egypt's population of 92 million, have long complained of marginalisation in the Muslim-majority country.
Egypt has the largest Christian community in the Middle East.
While most of Egypt's Christians are Coptic Orthodox, about 272,000 are Catholic.
Francis's visit comes 17 years after Pope John Paul II made a trip to the Arab world's most populous nation.