HAVANA — Pope Francis met Cuba's revolutionary leader Fidel Castro and celebrated Mass with tens of thousands of followers in Havana's Revolution Square on Sunday as police prevented some dissidents from getting close to the pontiff. Francis and Castro discussed religion and world affairs at the 89-year-old retired president's home, just hours after the pope warned Cubans of the dangers of ideology and the lure of selfishness as their Communist-ruled country enters a new era of closer ties with the United States. Vatican spokesman Father Federico Lombardi said the meeting, which also included Castro's wife and other family members, was "very relaxed, fraternal and friendly." Francis, 78, 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 jacket, 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. The pope has drawn widespread praise in Cuba for his behind-the-scenes role in supporting negotiations last year that led to a historic rapprochement between the United States and Cuba. His visit is aimed at further improving ties between the government and the Roman Catholic Church, and encouraging a more open society in Cuba. On Sunday morning, he sprinkled his mainly religious homily 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 — Fidel's younger brother — and top government officials. Francis has avoided calling for greater political freedoms in Cuba but the issue is never far below the surface on this and previous papal visits. An estimated 50 government opponents have been detained and prevented from attending papal events since Francis arrived on Saturday, according to the dissident Cuban Commission for Human Rights and National Reconciliation. Two prominent dissidents said they were stopped by state security agents for a second straight day on Sunday, when they were trying to reach the pope's evening prayers service in Havana's cathedral. The two women, Miriam Leiva and Martha Beatriz Roque, said they had been invited to the service by the Vatican's diplomatic envoys. A Vatican spokesman said some Cubans had been invited but he could not confirm their names. Earlier on Sunday, four dissidents who tried to deliver a letter to the pope were detained near Revolution Square after police knocked them to the ground and confiscated leaflets printed with prayers. One of them got close enough to make physical contact with Francis in his open-sided popemobile. The Patriotic Union of Cuba (UNPACU), the country's largest dissident group, said the four were still in jail late on Sunday while 17 other detained activists were released. As he celebrated Mass, Francis spoke beneath huge portraits of revolutionary leaders Ernesto "Che" Guevara and Camilo Cienfuegos built into the facades of state buildings in Revolution Square. To welcome the pope, a similarly giant poster of Jesus Christ was hung nearby. 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". He 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". Later on Sunday, the pope held a rally with young people, putting aside his prepared comments and clearly enjoying the chance to improvise and tell jokes in Spanish, their common native language. He told them to have the courage to think outside the box after hearing one of them say Cuba's youth were united in their desire for "profound change" in the country. Francis also went to the Palace of the Revolution for an hour-long private meeting with 84-year-old President Raul Castro. An atheist like his brother, Castro surprised the pope by giving him a sculpture of a life-sized Jesus Christ nailed to a cross made of oars and adorned with fishing nets. While the Castro brothers repressed the Catholic Church in the early decades of their revolution, they have both eased off in the last two decades, allowing more religious freedoms and more space for the Church to operate and even run schools. The changes have helped improve the government's image and some dissident groups complain the Church has not pushed hard enough for greater political freedoms on the island. Since arriving on Saturday, Francis has exhorted Cuba and the United States to deepen their detente, and encouraged Cuba to grant more freedom to the Church. Francis will celebrate Mass in Cuba's eastern cities of Holguin and Santiago before he flies out on Tuesday to the United States, where he will meet with President Barack Obama and address both the US Congress and the United Nations. — Reuters