Mr Cameron missed Benedict XVI's speech to politicians on Friday for the funeral of his father Ian, 77.
But at Birmingham Airport the pair had a private conversation on the tarmac, with the Premier overheard saying: "I've had an extraordinary last few days. It's difficult."
The Pontiff lay a kindly hand on his arm and told him: "You are in our thoughts."
Mr Cameron thanked him and, touching his arm again, Benedict reassured him: "You'll be fine."
The scenes came at the end of the Pope's historic four-day state visit.
Critics had predicted he would be greeted with a barrage of criticism - but the 83-year-old leader of the Catholic Church won the nation over with his dignity and humility.
Mr Cameron told him in a speech: "Your Holiness, you have spoken to a nation of six million Catholics but you have been heard by a nation of more than 60 million citizens.
"You have offered a message to each and every one of us to follow our conscience - to ask not what are my entitlements, but what are my responsibilities, to ask not what we can do for ourselves, but what we can do for others."
Before exchanging a warm, double-handed handshake, Mr Cameron concluded: "Your Holiness, your presence here has been a great honour for our country.
"Now you are leaving us - and I hope with strong memories.
"When you think of our country, think of it as one that not only cherishes faith, but one that is deeply, but quietly, compassionate."
The Pontiff responded: "Thank you for the warmth of your welcome and for the hospitality that I have enjoyed. During my time with you, I have been able to meet representatives of the many communities, cultures, languages and religions that make up British society.
"The very diversity of modern Britain is a challenge to its Government and people, but it also represents a great opportunity to further intercultural and inter-religious dialogue for the enrichment of the entire community."
After the formalities, he climbed the steps to his Alitalia jet, turned, clasped his hands together in prayer and modestly bowed in thanks for the generous goodbye.
Earlier he addressed a crowd of more than 70,000 in Birmingham - taking the number of people who have seen him on this trip to more than half a million.
A Vatican source said: "The crowd numbers at the official events have been fantastic but what is also amazing is the spontaneity of people who have just lined the streets."
Thousands of worshippers had begun gathering at dawn yesterday - six hours before the mass, shown on giant screens. They refused to let non-stop rain dampen their enthusiasm. Then the clouds parted as the Pope arrived at a temporary white "cathedral" built at the foot of the Lickey Hills in Cofton Park.
There were cheers as he beatified Cardinal John Newman, a 19th Century Catholic convert who spent much of his life in the Midlands.
Benedict smiled and waved from his Popemobile and stopped to bless and kiss two babies who were held up to him. Ese Ijasan, 30, from Manchester, beamed with joy after her daughter Aderonke, ten months, was picked from the masses.
The Salford University student said: "It is the biggest thing that has ever happened to me, ever."
The German-born Pope braved difficult memories of his early life as, on the 70th anniversary of the Battle of Britain, he spoke of the defeat of the Nazis.
Benedict - conscripted into the Hitler Youth as a teenager - said: "For me as one who lived and suffered through the dark days of the Nazi regime in Germany, it is deeply moving to be here with you on this occasion, and to recall how many of your fellow citizens sacrificed their lives, courageously resisting the forces of that evil ideology.
"My thoughts go, in particular, to nearby Coventry, which suffered such heavy bombardment and massive loss of life in November 1940.
"Seventy years later, we recall with shame and horror the dreadful toll of death and destruction that war brings in its wake, and we renew our resolve to work for peace and reconciliation wherever the threat of conflict looms."
Crowds in brightly-coloured raincoats waved papal flags and banners - one proclaiming: "We Love U Papa More Than Beans on Toast."
Benedict's state visit had begun with a welcome from the Queen and Prince Philip in Edinburgh on Thursday.
On Friday he gave a "Big Assembly" to 4,000 children in Twickenham, South West London, before meeting with the Archbishop of Canterbury Dr Rowan Williams in Lambeth Palace.
That evening, he gave an impressive address in Westminster Hall to an audience including four former PMs - Baroness Thatcher, John Major, Tony Blair and Gordon Brown.
And he became the first Pope to set foot inside Westminster Abbey, where he gave a joint address with Dr Williams.
A key moment for winning over his critics came on Saturday, when the Pope told of his "deep sorrow and shame" after meeting five sex abuse victims of priests.
SIC: TS/UK