David Jackson and Alan Gomez

USA TODAY

What started out as a proposed prisoner swap between the United States and Cuba turned into a historic shift in relations between the two countries, one devised during secret meetings abroad and resulting in the re-establishment of diplomatic relations after more than five decades.

The two countries, separated by just 90 miles of water, once had the world on the brink of nuclear war, an episode that prompted 50 years of a U.S. economic embargo on the island and anti-American rage from Cuban President Fidel Castro. Now, the countries are preparing to open embassies in each other's capitals and increase the flow of people and capital between them.

At the White House on Wednesday, President Obama called the move an end to "an outdated approach that, for decades, has failed to advance our interests." In Havana, Cuban President Raúl Castro, who took over the country when his brother fell ill in 2008, welcomed the new ties to the United States while acknowledging numerous issues remained.

The deal was finalized when two Americans had returned home from Cuban prisons. One was Alan Gross, a Maryland man who spent more than five years in a Cuban prison after he was arrested while distributing communications equipment on the island while working for the U.S. Agency for International Development. The second was described as an "intelligence asset" who had spent more than 20 years in Cuban prisons, according to three senior White House officials who were not authorized to speak publicly.

In exchange, three Cubans who had been convicted of espionage and other charges in the United States were sent home.

But the agreement will resonate far beyond Wednesday's flights, as Secretary of State John Kerry prepares for his first trip to Cuba and both sides work out the long list of changes they have agreed to make.

"This is the biggest shift in U.S.-Cuba relations in 50 years," said Ric Herrero, executive director of #CubaNow, which has advocated that empowering Cubans is the quickest way to a downfall of the Cuban regime.

The embargo has had little effect on Cuba's regime, Obama said, and encouraging more engagement will help promote reform in the long run. He likened the move to normalization of relations with other communist nations like China and Vietnam, the latter a country "where we fought a war that claimed more Americans than any Cold War confrontation."

The United States is now choosing "to cut loose the shackles of the past so as to reach for a better future," Obama said, "for the Cuban people, for the American people, for our entire hemisphere and for the world."

The U.S. and Cuba clashed repeatedly in the decades after the communist revolution, from reported U.S.-backed assassination plots targeting Castro to the placement of Russian missiles in Cuba that led to a near nuclear war in 1962. Successive presidents, Republican and Democratic, refused to change the economic embargo against Cuba.

As Obama spoke, Raúl Castro tempered expectations, saying, "This in no way means that the heart of the matter has been solved."

Obama and Raúl Castro spoke by phone Tuesday about the agreement, officials said, the first direct contact between American and Cuban leaders since Fidel Castro took control.

A surprise intermediary was Pope Francis, said the officials, who spoke on condition of anonymity because they were not authorized to speak publicly. He sent a letter about Cuba to Obama and Raúl Castro, officials said, and Obama and the pope discussed the topic at the Vatican in March. Secret negotiations between the two nations were also conducted in Canada, the officials said.

The agreement includes Cuba's release of Alan Gross, an American citizen arrested in 2009 on espionage charges for trying to provide Internet service to Cuban residents. Obama spoke with Gross by phone as he flew back to the United States.

Cuba, the officials said, also released an unnamed "intelligence asset" who had been imprisoned there for two decades. The asset, intelligence officials said, had helped unmask Cuban agents operating in the United States. In exchange, the United States sent three Cubans accused of spying and imprisoned here to Cuba, the officials said.

Anti-Castro Republicans, and some Democrats, attacked the announcement.

Sen. Robert Menendez, D-N.J., a Cuban-American Democrat and the outgoing chairman of the Senate Foreign Relations Committee, said, "President Obama's actions have vindicated the brutal behavior of the Cuban government."

Other Democrats backed Obama. Sen. Harry Reid, D-Nev., the outgoing majority leader, said, "I remain concerned about human rights and political freedom inside Cuba, but I support moving forward toward a new path with Cuba."

Sen. Marco Rubio, a Cuban-American Republican from Florida and a possible Republican presidential candidate in 2016, said he rejoiced at Gross' release. But he condemned the rest of the deal as "the latest in a long line of failed attempts by President Obama to appease rogue regimes at all cost."

Also a member of the Foreign Relations Committee, Rubio said he would try to do what he could to "block this dangerous and desperate attempt by the president to burnish his legacy at the Cuban people's expense."

Rubio and other Republicans said the Obama administration should demand democratic reform in Cuba before making any concessions.

"Cuba is a dictatorship with a disastrous human rights record, and now President Obama has rewarded those dictators," said Jeb Bush, a former governor of Florida and another prospective Republican presidential candidate.

Addressing his critics, Obama said he respects "your passion" and "commitment to liberty and democracy" but disagrees on the best way to get there. "I do not believe we can keep doing the same thing for over five decades and expect a different result," the president said.

The White House, meanwhile, forwarded e-mails of support for the new Cuba policy from normally critical groups like the U.S. Chamber of Commerce.

The Vatican — which hosted a meeting of U.S. and Cuban officials in October — said in a statement that Pope Francis sends his "warm congratulations" on the new agreement. Francis will continue to support "initiatives which both nations will undertake to strengthen their bilateral relations and promote the well-being of their respective citizens."

Some changes to Cuba policy — including an absolute end to the embargo — would require congressional approval, and Republicans will control both the Senate and House starting next month. Officials said Obama is exploring what he can do through executive action, especially when it comes to easing the rules of the embargo.

Restrictions are being lifted on one notable product valued in the United States: Cuban cigars (though there will still be limits).

"Licensed U.S. travelers to Cuba will be authorized to import $400 worth of goods from Cuba, of which no more than $100 can consist of tobacco products and alcohol combined," said a White House statement on the new policy.

In terms of travel, the administration statement said licenses will be available for trips related to a dozen categories: (1) family visits; (2) official business of the U.S. government, foreign governments and certain intergovernmental organizations; (3) journalistic activity; (4) professional research and professional meetings; (5) educational activities.

Also on the travel list: (6) religious activities; (7) public performances, clinics, workshops, athletic and other competitions, and exhibitions; (8) support for the Cuban people; (9) humanitarian projects; (10) activities of private foundations or research or educational institutes; (11) exportation, importation or transmission of information or information materials; and (12) certain export transactions that may be considered for authorization under existing regulations and guidelines.

"The policy changes make it easier for Americans to provide business training for private Cuban businesses and small farmers and provide other support for the growth of Cuba's nascent private sector," said an administration statement.

Obama has instructed Kerry to begin immediate talks about re-establishing diplomatic relations with Cuba, including the reopening of an American Embassy in Havana and high-level visits between government officials.

For his part, Kerry said he is looking forward "to being the first secretary of State in 60 years to visit Cuba." The White House did not rule out a visit to Cuba by Obama himself in the future.

Gross' imprisonment had been an obstacle to talks about improving U.S.-Cuban relations, including the possibility of easing or even ending the American economic embargo against Cuba.

Cuba arrested Gross for trying to set up an Internet access system while working as a subcontractor with the U.S. Agency for International Development. The communist state, which regards USAID programs as attempts to undermine its government, sentenced Gross to 15 years in prison.