The Roman Catholic Church has brokered a historic deal to release 52 political prisoners in Cuba, following three-way talks between Cuban President Raul Castro, Spanish Foreign Secretary Miguel Angel Moratinos and Havana Cardinal Jaime Ortega.

“Five prisoners will be released immediately and will be able to travel to Spain accompanied by their families,” said a statement from the Cuban church. “Another 47 will be freed and will be able to leave the country over a period of three or four months from now.”

Six more of the jailed will be relocated to prisons closer to their families. Spain has agreed to take in all the exiles.

The agreement represents the largest number of political prisoners freed since ailing dictator Fidel Castro allowed 3,600 to leave for the United States in 1979.

The release of a sizable chunk of the 190 political prisoners estimated to remain in Cuban jails comes barely two weeks after Vatican foreign secretary Archbishop Dominique Mamberti’s visit to the island nation, where he held talks with Raul Castro.

The Catholic Church has been increasingly influential in winning concessions in Cuba. Ahead of Mamberti’s visit, Ortega had negotiated the release of a sick prisoner, transfers for 12 inmates held far from families and better medical care in jails.

Ortega described dialogue with the communist regime as a “process” that would continue with “agility.”