Summary Mediation by Pope Francis also played a key role when the secret talks were stalled.
PANAMA CITY (AFP) - From their handshake at a memorial service for Nelson Mandela to their historic meeting in Panama, Barack Obama and Raul Castro have gradually set aside decades of US-Cuban hostility to achieve a rapprochement long thought impossible.
The handshake in South Africa in December 2013, captured by cameras on the sidelines of Mandela s memorial, gave the first glimpse of a potential thaw between the old Cold War foes.
Obama had floated the idea several weeks earlier, when he said at a fundraiser in Miami that the United States needed to rethink its Cuba policy -- a politically risky move in the anti-Castro bastion.
What the world did not know was that behind the scenes, talks had already begun -- in June 2013 -- on restoring diplomatic ties severed in 1961, two years after the Cuban Revolution.
The negotiations were a tightly guarded secret right up to December 17 last year, when the two presidents announced their countries would normalize relations.
Several factors helped clear the way for the dramatic detente: Castro s economic reforms and less hostile rhetoric since taking over from his big brother Fidel in 2006, and shifting US attitudes toward the communist island.
Mediation by Pope Francis also played a key role when the secret talks were stalled in the spring of 2014.
According to the head of the Catholic Church in Cuba, Cardinal Jaime Ortega, the pope helped nudge the negotiations through difficult territory when he and Obama met at the Vatican in March last year.
"The pope spoke about the US embargo with Obama, who acknowledged that it was an obsolete measure taken before he was even born," Ortega, who also played a central part in the process, told an Argentine Catholic newspaper.
" There are obstacles. Those prisoners, " Obama told him, referring to the inmates whose release would later pave the way for the historic announcement: three Cuban intelligence agents jailed in the United States, as well as US contractor Alan Gross and a CIA operative jailed in Cuba.
According to Ortega s account, when Obama said he could not free the three Cubans, the pope pressed him to think of the big picture.
"Look, it s not just for the good of the Cuban people, who have suffered greatly. It s also for your government and you personally, for your country s policy toward Latin America, which is united in its rejection of this embargo," said the pope.
Ortega said the comment gave Obama pause and ultimately helped unblock the discussions.
Difficult, winding road
After that meeting, the pope wrote letters to both Obama and Castro inviting them to "resolve humanitarian questions of common interest, including the situation of certain prisoners."
That unprecedented move by the pontiff "reinforced the impetus and the momentum to move forward," said a senior US official.
In October, US and Cuban delegations met at the Vatican to finalize the terms of the deal, including the prisoner swap.
At the time, there were rumors of a prisoner exchange in diplomatic circles, but no one suspected the magnitude of the announcement setting aside more than half a century of bad blood.
High-level delegations from the two countries have since held three meetings on reopening embassies, restoring diplomatic ties and other issues still dividing the long-time foes.
The stumbling blocks include the US embargo, which will be trickier to resolve than the prisoner issue, since Obama would need the blessing of the Republican-controlled Congress to lift it.
The two presidents are both "deeply involved" in the process, said Cuban ex-diplomat and university professor Carlos Alzugaray, "even if it will be a difficult, winding road and may be short on time because everything could change when the next US president takes office in January 2017."
