Pope Benedict has urged Cubans to search for "authentic freedom" and wound up his trip with a meeting with the communist country's revolutionary icon Fidel Castro.

The two men spoke for about a half an hour in the Vatican embassy after the Pope celebrated an open-air mass for a crowd estimated by the Vatican at 300,000 people in Havana's Revolution Square.

Benedict, who said last week that communism no longer works in Cuba, pressed the government to let the Catholic Church teach religion in schools and universities.

Vatican spokesman Father Federico Lombardi said Mr Castro told the Pope he had watched the entire three-day trip on television.

They had an exchange of ideas about church liturgy, the world situation, and science.

"Castro asked the Pope 'What does a Pope do?' and the Pope told him of his ministry, his trips, and his service to the church," Fr Lombardi said.

Earlier the Pope, who leaves for Rome overnight, led a Mass in the square that Mr Castro, now 85, used to fill with big crowds for hours-long speeches.

Surrounded by ten-story high images of Castro's revolutionary comrades Ernesto "Che" Guevara and Camilo Cienfuegos, the Pope read a sermon that continued one of the main themes of his trip - that Cuba should build a more open society, based on truth, justice and reconciliation.

"The truth is a desire of the human person, the search for which always supposes the exercise of authentic freedom," he said.