The Pope prayed among ruined churches in Mosul, the former IS stronghold, before meeting Christians in Qaraqosh.
Celebrating Mass at a stadium in Irbil, the last big set piece of his visit, he said Iraq would remain in his heart.
Thousands of people attended the service despite Covid concerns.
In Mosul the Pope visited Church Square to pray for the victims of the war with the Islamic State group, which left thousands of civilians dead.
Surrounded by the tottering ruins of the square's four churches, he said the exodus of Christians from Iraq and the broader Middle East had done "incalculable harm not just to the individuals and communities concerned but also to the society they leave behind".
Referring to the historic region of Mesopotamia, which covered much of modern Iraq including Mosul, Pope Francis said: "How cruel it is that this country, the cradle of civilisation, should have been afflicted by so barbarous a blow, with ancient places of worship destroyed and many thousands of people - Muslims, Christians, Yazidis and others - forcibly displaced or killed.
"Today, however, we reaffirm our conviction that fraternity is more durable than fratricide, that hope is more powerful than hatred, that peace more powerful than war."
IS desecrated Christian places of worship, beheading religious statues and planting booby-trap bombs. Tens of thousands of Christians fled IS control while those who remained faced having their property stolen and choosing between paying a tax, converting to Islam, leaving or facing death.