HAVANA (Reuters) - Pope Francis met Cuba's revolutionary leader Fidel Castro on Sunday hours after warning Cubans to beware the dangers of ideology and the lure of selfishness as their country enters a new era of closer ties with the United States.
Latin America's first pope and Castro, the region's last surviving leftist icon of the 20th century, discussed religion and world affairs at the home of the 89-year-old retired president for about 40 minutes.
Vatican spokesman Father Federico Lombardi said the meeting, which included Castro's wife and other family members, was "very relaxed, fraternal and friendly."
Francis gave Castro several of his official papal writings, two books on spirituality and a book and CD on the writings of Father Armando Llorente, a priest who taught Castro in Jesuit prep school more than 70 years ago.
Castro, who wore a blue-and-white track suit, gave him a copy of "Fidel and Religion," a 1985 book of interviews with a Brazilian priest which lifted a taboo on speaking about religion in Cuba, then officially atheist.
Francis later went to the Palace of the Revolution, where he held private talks for about an hour with President Raul Castro, Fidel's 84-year-old younger brother.
Raul Castro, an atheist like his brother, surprised the pope by giving him a sculpture of a life-sized crucified Jesus Christ against a backdrop of fishing nets and oars.
Francis met with Fidel Castro, who built a one-party state that improved health and education services for Cubans but also limits democratic freedoms and represses dissent, after celebrating Mass in Havana's Revolution Square.
There, he spoke beneath massive portraits of revolutionary leaders Ernesto "Che" Guevara and Camilo Cienfuegos built into the facades of state buildings.
To welcome the pope, who helped bring about the recent rapprochement between Cuba and the United States, a similarly giant poster of Jesus Christ was hung nearby.
Francis delivered a mostly religious homily to the tens of thousands present, but sprinkled it with criticism of "elitism" and ideology.
"Service is never ideological for we do not serve ideas, we serve people," he said at the Mass, attended by President Raul Castro and top members of the communist government.
Cuban police kept some dissidents from attending the Mass and pounced on others apparently attempting to hand out flyers near the plaza.
In what government foes could see as criticism of party bureaucracy, the pope said Jesus' apostles foolishly argued about rank and he compared it to "those who climb the ladder most quickly to take the jobs which carry certain benefits".
Francis also appeared to appeal to Cubans to look after each other as the country faces social changes and new economic opportunities.
He said they should continue to be "at the service of the frailty of your brothers and sisters" and "not neglect them for plans which can be seductive, but are unconcerned about the face of the person beside you".
At the end of the Mass, the pope appealed to Colombia's government and Marxist FARC guerrillas to ensure that nearly three years of peace talks in Cuba are successful in order to end their "long night" of war.
Between 30-40 dissidents were detained to stop them attending papal events, a dissident human rights group said.
Security agents wrestled two men and a woman to the ground at the edge of Revolution Square, then led them off, after they started shouting and tried to hand out flyers, a Reuters witness said.
Arriving on Saturday, Francis exhorted Cuba and the United States to deepen their detente, and encouraged Cuba to grant more freedom to the Roman Catholic Church, which has re-emerged as a powerful force after suffering decades of repression.
"His visit is cause for hope in our aspirations for improvement," said biologist Benito Espinoza, 41, at Revolution Square. "We are an optimistic people, but we have suffered for many years."
Francis will fly from Cuba to Washington on Tuesday.
He will meet with Obama and address both the U.S. Congress and United Nations.
Additional reporting by Nelson Acosta, Andrew Cawthorne, Anahi Rama and Marc Frank; Editing by Ros Russell and Kieran Murray