The restoration of full diplomatic relations between the United States and Cuba, as well as a prisoner exchange that secured the release of American Alan Gross, was brokered, in part, by the Holy See.

A high-ranking Vatican official confirmed today that the Obama administration and the Vatican have been working together for more than a year to end decades of hostility and restore relations between the US and the Caribbean nation.

After 18 months of secret talks hosted largely by Canada and encouraged by Pope Francis, the pontiff hosted the final meeting at the Vatican in October between US and Cuban officials, according to the Vatican. The final agreement was reached during a telephone call between Obama and Castro Tuesday.

Pope Francis sent private letters to both President Obama and Cuban leader Raul Castro last year, the Vatican confirmed, and Obama said that he and the pope discussed Cuba during the president’s visit to the Vatican in March.

The pope’s involvement had its roots in Boston, according to the co-founder of a Cambridge-based conflict resolution group that asked Boston Cardinal Sean O’Malley to talk about Cuba with the pope.

O’Malley has visited Cuba seven times since his first trip in the 1980s, meeting with religious and government officials, including in 2012 as part of a delegation traveling with Pope Benedict XVI.

Timothy Phillips, whose group Beyond Conflict has participated in conflict resolution initiatives in Northern Ireland, South Africa, and several countries in Latin America, said his group decided to approach O’Malley about a year ago, to see if O’Malley would be willing to ask the pope to become directly involved in efforts to normalize relations with Cuba.

Phillips said he approached Boston advertising executive Jack Connors, an O’Malley confidante, who put a meeting together between archdiocese officials and Beyond Conflict last March.

“The idea was to get the pope to bring this up with President Obama when he visited the Vatican,” said Phillips. “Cardinal O’Malley was very receptive, and in the end, so was the pope.”

Phillips said O’Malley remained involved in the quiet diplomacy right until the end, meeting with the pope in Rome recently.

In his announcement of the new diplomatic relations today, President Obama thanked Pope Francis for his role in the process, “whose moral example shows us the importance of pursuing the world as it should be, rather than simply settling for the world as it is.”

US Sen. Marco Rubio, a Florida Republican whose parents immigrated from Cuba in 1956, blasted Obama for not securing more concessions from Cuba in exchange for restoring diplomatic relations, and also took a swipe at Pope Francis’ role.

“I would … ask His Holiness to take up the cause of freedom and democracy, which is critical for a free people — for a people to truly be free,” Rubio, a Catholic, told Talking Points Memo. “I think the people of Cuba deserve the same chances to have democracy as the people of Argentina have had, where he comes from; as the people of Italy have, where he now lives.

“Obviously the Vatican’s its own state, but very nearby,” the senator said. “My point is I hope that people with that sort of prestige on the world stage will take up the cause of freedom and democracy. The Cuban people are the only people in this hemisphere that have not been able to elect a leader in more than 55 or 60 years. That’s outrageous.”

But the Catholic leader of Miami, home to the nation’s largest Cuban population, praised the pope’s involvement.

“Pope Francis did what popes are supposed to do: build bridges and promote peace. He acted much like his namesake, Francis of Assisi,” Archbishop Thomas Wenski told Crux in a telephone interview.

Still, he acknowledged that some Cuban-Americans will not be happy. “The pain of these people is real, they suffered, especially in the early years of the revolution, great humiliations, and often imprisonment or death — their own imprisonment or the imprisonment of relatives and loved ones — so the pain is real,” he said.

Still, he defended the deal, and the Vatican’s involvement.

“I think basically we have to encourage [skeptics] to wait and see,” he said. “Again, the policy of confrontation and isolation after 50 years has not resulted in a change of regime, so we have to see whether a policy that starts from more engagement will lead to positive changes that will be welcome by Cubans on both sides of the Florida Strait.”

Wenski, one of the Catholic Church’s most outspoken advocates for immigration reform, said he pressed the White House to act on Cuba during a meeting with Chief of Staff Denis McDonough in May, and called today’s announcement “just a step in what’s going to be a very long process. I think more significant things are hopefully in the future.”

Gross, a contractor, was imprisoned five years ago, accused by Cuban officials of spying. He maintained he was installing computers for Cuban Jews. The United States, in turn, will release Cuban prisoners held here.

The US Ambassador to the Holy See, Kenneth Hackett, told Crux that the US government was “grateful to the Holy See for the key role it played in US discussions with Cuba that led to today’s prisoner exchanges by both sides.”

Hackett confirmed that Pope Francis sent letters to President Obama and to Cuban President Raul Castro this past summer urging the two sides to restore diplomatic relations.

“A senior Vatican official also played an important part in this historic moment by meeting with US and Cuban delegations in October to help bring the negotiations to a successful conclusion,” Hackett said.

The Vatican Secretariat of State posted the following statement on its website:

The Holy Father wishes to express his warm congratulations for the historic decision taken by the Governments of the United States of America and Cuba to establish diplomatic relations, with the aim of overcoming, in the interest of the citizens of both countries, the difficulties which have marked their recent history.

In recent months, Pope Francis wrote letters to the President of the Republic of Cuba, His Excellency Mr Raúl Castro, and the President of the United States, The Honorable Barack H. Obama, and invited them to resolve humanitarian questions of common interest, including the situation of certain prisoners, in order to initiate a new phase in relations between the two Parties.

The Holy See received Delegations of the two countries in the Vatican last October and provided its good offices to facilitate a constructive dialogue on delicate matters, resulting in solutions acceptable to both Parties.

The Holy See will continue to assure its support for initiatives which both nations will undertake to strengthen their bilateral relations and promote the wellbeing of their respective citizens.

Cuba and the Vatican established diplomatic relations in 1996, in part, some believed, in an attempt to loosen US trade restrictions.

Pope John Paul II then traveled to the island nation in January 1998, the first pope ever to visit.

In 2012, his predecessor, Pope Benedict XVI, also visited Cuba, where he was greeted by President Raul Castro and celebrated an outdoor Mass in Revolution Square for more than 200,000 people. The pope said ahead of his visit to Cuba that the Marxist government “no longer corresponds to reality,” but also criticized the US embargo, according to CNN.

US Secretary of State John Kerry has visited the Vatican in his official capacity three times: in January, March, and again just days ago, when he met with his Holy See counterpart, Archbishop Pietro Parolin. Reports from that meeting said that the Vatican again asked the United States to close Guantamo Bay, the US prison in Cuba that houses suspected terrorists.

Inés San Martín reported from Rome. Boston Globe staff reporter Kevin Cullen contributed to this report.