Pope Francis met privately with Fidel and Raúl Castro on Sunday and delivered a resounding message to a country that has lived under the brothers’ communist rule for more than five decades, urging a life of service “to people, not ideas.”

On a day packed with speeches, ceremonies and meetings, Francis arrived before 9 a.m. at Havana’s Plaza of the Revolution for a large outdoor Mass celebration, smiling and waving from his popemobile and stopping to embrace worshipers and bless children.

Flanked by an enormous portrait of Ernesto “Che” Guevara — a different sort of Argentine — Francis called on Cubans to “live authentically in a concrete commitment to our neighbor.”

“Service is never ideological, for we do not serve ideas, we serve people,” the pope said, his words echoing across a square long associated with the older Castro’s burning oratory during the early years of his Marxist revolution.

Although many bishops in attendance sat on a shaded dais behind him, Francis opted to stand under the harsh Cuban sun despite his stuffy vestments. The heat did not appear to faze him.

As Francis arrived at the plaza, one anti-government activist who approached him grabbed onto the popemobile and appeared to begin pleading with him. As security agents pulled the man away, he shouted “Freedom!” and two other activists joined him, throwing fliers into the air until they, too, were tackled and removed. Security teams quickly moved in to gather up the leaflets.

Prominent Cuban dissidents who tried to meet with Francis were again detained Sunday, including several who said they were invited by the Vatican to meet him at Havana’s main cathedral. The Rev. Federico Lombardi, the Vatican spokesman, told reporters he “could not rule out” that some opposition members had been invited to see Francis but were prevented from doing so by Cuban authorities.

“These were no meetings scheduled” with dissidents, he said. “I don’t have any information.”

In his Mass celebration Sunday morning, Francis built on his calls for reconciliation and dialogue with appeals to both Cuba’s communists and government opponents, urging care for the neediest and the most vulnerable.

Reading serenely from his written homily, the pontiff criticized those who feign to serve others but abuse power to “climb the ladder most quickly to take the jobs which carry certain benefits,” a statement likely to be interpreted by many here as a rebuke to the bureaucratic culture of Cuban socialism.

The plaza is the same place where Pope John Paul II spoke in 1998 and Pope Benedict XVI did in 2012, and Sunday’s crowd did not appear especially large by the standards of the capacious square. According to Vatican estimates, 200,000 attended the Mass, but most estimates were considerably lower, and the crowd did not appear especially large by the standards of the capacious square. Still, the evolution of church-state relations in Cuba over the past several decades produced a remarkable backdrop for Francis’s Mass in the square.

To his left was a large mural with the image of Guevara, the guerrilla icon and a militant atheist, and a portrait of revolutionary comrade Camilo Cienfuegos. Directly across the plaza from the pontiff, draped on the facade of Cuba’s National Library, was a massive banner depicting Jesus and bearing the message “Come to me.”

In the audience, Argentine President Cristina Fernández de Kirchner watched, cooling herself with a fan and seated beside Cuban President Raúl Castro and other top communist officials.

After the Mass, Francis went to the home of ailing Fidel Castro, 89, for a “30- to ­40-minute” visit that the Vatican described as “fraternal” and “informal.” Castro’s wife, children and grandchildren also were present, said Lombardi, the Vatican spokesman, and the two exchanged books and discussed their mutual concerns about climate change.

Francis brought two books written by an Italian theologian; Castro gave the pope a copy of “Fidel and Religion,” written by the Brazilian priest and activist Frei Betto. Lombardi said Francis also gave Castro a copy of a book by one of the leader’s former teachers at the Jesuit prep school he attended in the 1940s, Colegio Belen, which the government long ago converted into a military academy.

In the afternoon, the pope met privately with Raúl Castro, 84, at the Palace of the Revolution, and the two could be seen talking intently, leaning toward each other.

Later, Francis arrived at Havana’s Great Cathedral, tossing aside prepared remarks for a sermon to nuns, priests, bishops and seminarians that urged them to embrace “poverty and mercy.”

“That’s where you will find Jesus,” he told them.

He then proceeded outside to address a large crowd of young Cubans who stood in the rain listening raptly to his every word. Again going off script, Francis told them to “dream” and resist the temptations of a “spiritually sterile” life, encouraging them to embrace others who think differently.

“What a cool pope!” the crowd chanted as he bid farewell and retired for the evening. Francis is scheduled to depart Monday morning for a flight to the city of Holguin in eastern Cuba, where he will celebrate a 10:30 a.m. Mass.

He will not return to Havana and is scheduled to depart Cuba for the United States on Tuesday afternoon.

During the Mass on Sunday morning in Havana, Cardinal Jaime Ortega, who has led the island’s Catholic Church for decades and is often criticized by Castro opponents as being too accommodating to the communist authorities, followed the pope’s homily with the most specific remarks of the day regarding the island’s ­long-troubled relationship with the United States.

Gratitude toward the pope is shared “by the Cuban people living here and in the United States,” Ortega said, calling Francis’s role in the recent rapprochement between Cuba and the United States a reflection “of the Christian spirit of mercy and forgiveness” and “the longing for reconciliation between all Cubans, those who live in Cuba and those abroad.”

“Love and forgiveness are the only valid path to a true and peaceful renovation of our nation,” Ortega said.

Francis also read a statement at Mass directed at Colombia, whose government has been engaged in peace talks with Marxist FARC rebels for nearly three years in Havana.

“May the long night of pain and violence, with the support of all Colombians, become an unending day of concord, justice, fraternity and love, in respect for institutions and for national and international law, so that there may be lasting peace,” he said, referring to the half-century-old conflict that has left more than 200,000 Colombians dead.

“We do not have the right to allow ourselves yet another failure on this path of peace and reconciliation,” said Francis, thanking Raúl Castro for supporting the peace negotiations.

Cubans from all across the island came to the plaza for the Mass, arriving long before dawn, with many sleeping on the concrete until sunrise.

Francis is a popular figure among Catholics and ­non-Catholics alike on the island, in particular for his role in facilitating negotiations between the Castro government and the Obama administration, which led to the restoration of diplomatic relations in July.

“This pope is very worried about the problems of the world,” said Maria Elena Pendás, 50, who came with her family from a rural area of Cuba’s Pinar del Rio province, where they grow mangos as well as citrus and other fruit. “He’s very concerned with the environment, and that’s important to me.”

Alexander Alvarez, 51, came from the central city of Camaguey, where he is a custodian at a church. He also brought his dog, Toby, a Pekingese with a toothy underbite, who he said shares his devotion.

“He sleeps every night in the altar we have to the Virgin,” Alvarez said.

Many in the crowd waved the flags of Cuba and the Vatican.

“I think this pope is a moral authority in the world,” said Marisa Quintana, 64. “He’s capable of healing relations between nations.”

“Our country has gone through so much,” she said. “This system is one of courage,” she added, referring to the Castros’ socialist revolution, “but it has left many families divided.”

Quintana’s son and sister live in Spain. Her brother is in New York. Her mother died there.

But Quintana said she feels “less alone,” because the pope is helping bridge divisions between Cuba and the United States.

“Let us not forget the good news we have heard today,” Francis said as he concluded his homily, “the importance of a people, a nation, and the importance of individuals, which is always based on how they seek to serve their vulnerable brothers and sisters. Here we encounter one of the fruits of a true humanity.”

“Brothers and sisters,” he said, “whoever does not live to serve has no purpose in life.”

Read more:

Why Pope Francis’s silence on black America may soon end

Why everyone wants a piece of Pope Francis for themselves

Today’s coverage from Post correspondents around the world