The US and Cuba have agreed to open embassies in each other's capitals, the biggest tangible step in the countries' historic bid to restore ties after more than half a century of hostilities.

President Barack Obama announced the agreement at the White House and the US Embassy in Havana is scheduled to open later this month.

The US and Cuba have been negotiating the re-establishment of embassies following a surprise December announcement that the long-time foes were restarting diplomatic relations.

For Mr Obama, ending the US freeze with Cuba is central to his foreign policy legacy. He has long touted the value of direct engagement with global foes and has argued the US embargo on the communist island just 90 miles south of Florida has been ineffective.

Following 18 months of secret negotiations brokered by Pope Francis and Canada, the two leaders announced separately but simultaneously last December they planned to normalise relations.

US Secretary of State John Kerry is expected at a flag-raising ceremony in Havana later this month, when the so-called US interests section will become a full embassy. Cuba's mission in Washington will undergo a similar upgrade.

The deal last December also included a prisoner swap and sought to relegate to history 56 years of recriminations that have predominated ever since Fidel Castro's rebels overthrew the U.S.-backed government of Fulgencio Batista in 1959.

Two years later, US President Dwight Eisenhower closed the US embassy in Havana, less than three weeks before President-elect John F. Kennedy was due to take office.

By April of that year, Kennedy would authorize the U.S.-organized invasion of Cuba by a force of Cuban exiles. The attack at the Bay of Pigs failed and reinforced Castro's standing at home and abroad.

In October 1962, Washington and Moscow nearly came to nuclear war over Soviet missiles stationed in Cuba.

Fidel Castro, 88, remained in power until 2008, when he handed off to his younger brother Raul Castro, 84.

With diplomatic relations restored, the United States and Cuba will turn to the more difficult task of normalising overall relations.

Major obstacles include the comprehensive US economic embargo of Cuba and the US naval base at Cuba's Guantanamo Bay, which the US has leased since 1903.