The secret diplomacy that would upend a half century of enmity between the United States and Cuba was a year and half in the making. It started with an American overture to Cuba and a series of nine meetings in Canada, beginning in June last year, according to senior administration officials. The process involved an unusual intervention by Pope Francis, who opened the Vatican to help seal an agreement and wrote personal letters to President Barack Obama and Cuban President Raul Castro calling for a prisoner exchange and the resumption of diplomatic relations between the sides. For a time, the talks stalled on definitions of who was a spy but ended on an emotional high note as three planes ferried released prisoners between the two countries in a choreographed swap. The back-channel negotiations were conducted not by professional diplomats but by two of Obama's national security advisers, making it clear to the Cubans that the opening was coming directly from the Obama White House. Along the way, administration officials from Secretary of State John Kerry on down used every opportunity to reiterate that the future of US-Cuba relations was entwined with that of American contractor Alan Gross, whose physical and emotional stamina seemed to be declining after five years in captivity. In four conversations this summer with Cuban Foreign Minister Bruno Rodriguez Parrilla, Kerry said that relations between the two countries would "never, never" improve so long as Gross was in a Cuban prison cell, said a senior State Department official. Though he made it easier for Cuban Americans to send small sums of money and visit relatives on the island, the likely fallout from a more dramatic policy change was too daunting during his first term. But Obama believed continued, permanent estrangement was untenable, officials said. During the 2012 Summit of the Americas, he was on the receiving end of a barrage of complaints from Latin American governments over what they saw as the United States' obsession with Cuba. Early last year, as Obama began his second term, he authorised exploratory talks with Cuba. On both sides, the governments decided to forgo traditional diplomatic channels, and place the talks on the level of presidential administration to presidential administration. The White House chose deputy national security adviser Benjamin Rhodes, a trusted senior Obama aide, and Ricardo Zuniga, the senior NSC director for Latin America with previous service at the US interests section in Havana. The Cubans picked comparable aides. In June of 2013 came the first face-to-face talks in Ottawa, which has friendly diplomatic relations with Cuba. Over the next 18 months, the teams met there a total of nine times. Havana's opening proposal was for a spy exchange - Gross for the three still-jailed prisoners of the Cuban Five, who reported to Havana on the activities of anti-Castro Cubans in Miami. The Americans refused, insisting that Gross was a USAID subcontractor carrying out a legitimate mission. Then, Obama in March paid a visit to Pope Francis at the Vatican and their talk turned to Cuba. Francis, the first Latin American pope, offered to help resolve issues between the two countries, and subsequently sent letters to both Obama and Castro. In October, the two teams travelled to Rome to meet directly with Vatican officials. The deal for the prisoner exchange was finalised there, though the talks continued in Canada up through November. Toward the end, events propelled Obama along. After the midterm elections, he indicated that he felt more able to take unilateral actions using his executive powers. On Tuesday, Obama spent close to an hour on the phone with Castro, the first presidential-level conversation involving the two countries since Cuba's 1959 revolution. And on Wednesday, Obama spoke from the White House in a televised address to the American people. "Today, America chooses to cut loose the shackles of the past, so as to reach for a better future for the Cuban people, for the American people, for our entire hemisphere and for the world." Only a few hours earlier, three planes were cutting through the morning skies. One left Miami for Havana carrying three Cubans who were convicted in 2011 on spying charges. Another plane flew in the opposite direction, transporting an unnamed US spy, jailed nearly 20 years for providing information on Cuban moles in the United States. The third had departed from Joint Base Andrews before dawn for a military installation near Havana. There, the head of the US interests section escorted Gross to his waiting wife, Judy. "You're free," Senator Patrick Leahy, a Vermont Democrat who also was on board the plane, said he told Gross. "I finally know I'm free," Gross replied.