Pope Francis on Sunday hailed the value of the elderly, including his predecessor Benedict XVI, who joined him at a ceremony in St. Peter's Square honoring the contribution of grandparents to society.

Tens of thousands of people, many of them grandparents and grandchildren, applauded when Francis said that Benedict's living in papal retirement at the Vatican is "like having the wise grandfather at home." Benedict, seated, clasped his hands together and extended them toward Francis in a sign of gratitude.

Francis warmly embraced the frail, 87-year-old Benedict, who used a cane and wore a long white coat despite the warmth of a summerlike morning.

Francis, 77, said group homes for elderly with no families were OK as long as they are "not prisons." He lamented that the elderly are often "forgotten, hidden, neglected," calling that treatment tantamount to a kind of euthanasia.

Referring also to himself, Francis described old age as a "time of grace."

"Grandparents who have received the blessing of seeing the children of their children are entrusted with a great task: transmitting the experience of life, the history of a family, of a community, of a people, sharing, with simplicity, wisdom, and faith itself -- the most precious inheritance," the pope added.

"A people that doesn't take care of its grandparents and treat them well is a people with no future," said Francis, decrying societies that prize productivity and thus marginalize elderly and the young.

Opera-and-pop star Andrea Bocelli was among those singing at the ceremony.

Francis greeted an elderly Iraqi refugee couple, who are married for 51 years and who recently fled violence against Kurds.

In October, Francis will lead bishops from around the world during weeks of discussion on family issues.