Image copyright AP Image caption Alan Gross with wife Judy before his arrest

The US and Cuba have struck a prisoner swap deal that involves the release of American Alan Gross and three Cubans, US officials have announced.

Mr Gross, 65, has spent five years behind bars after being accused of subversion on the communist island.

He left Cuba on a US government plane and was freed on humanitarian grounds, a US official told Associated Press.

His arrest and imprisonment has undermined attempts to thaw diplomatic relations between the two countries.

American officials told Associated Press the two countries will start talks to normalise relations and the US is looking to open an embassy in Havana in the coming months.

The three Cubans released in the US are part of the so-called Cuban Five convicted of spying.

Prosecutors said the five had sought to infiltrate US military bases and spied on Cuban exiles in Florida.

Two were recently allowed to return to Cuba after finishing their sentences.

Image copyright AP Image caption Fernando Gonzalez embraced his mother amid a hero's welcome when released in February

Mr Gross, who has been in declining health, was jailed for 15 years for committing "acts against the integrity of the state".

His work in building internet access for local communities involved bringing in satellite equipment that is illegal in Cuba.

The Cuban authorities saw his activities as a covert attempt at regime change, although Washington protested his innocence.

This week, former US President Bill Clinton accused Cuba of playing a "very dangerous game to hold Gross where his health is getting worse".

Key dates

2001: Five Cubans, dubbed the Cuban Five, are convicted in Miami and given long sentences for spying for the Cuban government. Their case becomes a rallying cry for the Havana government

2008: Raul Castro officially takes over as Cuban president. Washington calls for free and fair elections, and says its trade embargo will remain

Dec 2009: US citizen Alan Gross detained in Cuba accused of spying for Washington

Oct 2011: One of the Cuban Five, Rene Gonzalez, is freed as scheduled from a Florida jail

Dec 2013: US President Barack Obama and Raul Castro shake hands at Nelson Mandela's funeral - the first such public gesture since the 1959 revolution

Feb 2014: The second of the Cuban Five, Fernando Gonzalez, is freed after completing his sentence

17 December 2014: Alan Gross is released by Cuba after five years in captivity