Pope Benedict ended his visit to Cuba on Wednesday by urging the communist-run island to search for authentic freedom and condemning a 50-year-old U.S. trade embargo while also making time to meet with ailing revolutionary icon Fidel Castro.

The leader of the world's 1.2 billon Catholics led a public Mass in Havana's vast Revolution Square where Castro once drew huge crowds to listen to his fiery speeches.

Surrounded by ten-story high images of Castro's late comrades Ernesto Che Guevara and Camilo Cienfuegos, the pope read a sermon that continued the main themes of his trip - that Cuba must build a more open, less controlled society, with a bigger role for the Roman Catholic Church as a buffer against trauma or social upheaval.

The Vatican estimated that 300,000 people were in the crowd, though Reuters journalists put the figure considerably lower.

Benedict's visit came as President Raul Castro has undertaken economic reforms to encourage more private enterprise and embraced the Church as an interlocutor on social issues, including human rights.

But while Benedict is urging Cuba to make deeper changes, the government sees its reforms as a way of strengthening communist rule, not weakening it.

After the Mass, Fidel Castro, the president's older brother, visited Benedict at the Vatican embassy where the two octogenarian world leaders with widely divergent political views chatted for 30 minutes in what a Vatican spokesman called a very cordial atmosphere.

They discussed serious issues such as Church liturgy and the state of the world, but also joked about their age -- Castro is 85 and Benedict is 84. At one point, Castro asked a simple question - what does a pope do?

The pope told him of his ministry, his trips, and his service to the Church, said spokesman Federico Lombardi.

Photographs showed Castro and the pope standing and smiling, with Castro - who stepped down as Cuban leader in 2008 due to poor health - wearing a dark track suit with a scarf around his neck that seemed out of place on a warm day.

The friendly meeting contrasted with the beginning of Benedict's visit when he sharply criticized the communist system that Castro put in place after taking power in a 1959 revolution and continues to defend as the last, best hope of mankind.

On the flight to Mexico beginning his Latin American trip on Friday, the pope said communism had failed in Cuba and that the country needs a new economic model.

In a possible dig at Marxism on Wednesday, Benedict also said some wrongly interpret this search for the truth, leading them to irrationality and fanaticism; they close themselves in 'their truth,' and try to impose it on others.

He said the said the search for truth always supposes the exercise of authentic freedom. But he also railed against the U.S. trade embargo.

May no-one feel excluded ... from taking up this exciting search for his or her basic freedoms, or excused from this by indolence or lack of material resources, a situation which is worsened when restrictive economic measures, imposed from outside the country, unfairly burden its people, the pontiff said.

Since his arrival on Monday in the eastern city of Santiago de Cuba, Benedict made thinly-veiled references to Cuban dissidents, political prisoners, Cuban exiles and the need for the Caribbean island to push ahead with its economic reforms.

While he acknowledged with joy the great improvements in Church-state relations since Pope John Paul's 1998 Cuba visit, he added: Nonetheless, this must continue forwards, and I wish to encourage the country's government authorities to strengthen what has already been achieved and advance along this path.

The Church wants to get back some of the ground it lost after the revolution, so the pope urged the government to let it do more social work and play a bigger role in education.

Marino Murillo, a vice president in the Council of Ministers and the country's economic reforms czar, made it clear that change to Cuba's one-party political system is not in the works.

In Cuba there won't be political reform, he said at a news conference. We are talking about the update of the Cuban economic model to make our socialism sustainable.

(Additional reporting by Simon Gardner, Rosa Tania Valdes and Nelson Acosta; Editing by David Adams and Kieran Murray)