The rum, the sun, the rum, the fishing, the rum … there was almost nothing that Ernest Hemingway didn't like about Cuba, which was his home from 1939 to 1960 – when he heard that Fidel Castro's new revolutionary government might be confiscating all American property.

The cult of the hard-living, hard-writing author has become inextricably entangled with that of the Caribbean island – and as the cold war that drove him to leave finally thaws, the team making a Hemingway biopic has become the first to film a major Hollywood movie there in more than half a century.

Papa, which has just completed filming, tells the true story of the friendship between the author and a young journalist, and after years of negotiation it won unprecedented cooperation from the Cuban and US authorities.

The joint Canadian-Cuban-US production won a licence from the US Treasury exempting it from the trade embargo that has been in place since Castro came to power in 1959, though an undisclosed cap on spending in Cuba was imposed as part of the conditions.

The director, Bob Yari, told the Associated Press filming anywhere else was not an option, despite hiccups including lack of internet access and last-minute cancellations of consent for filming in a boat, and reports that the actor Sharon Stone is suing him over allegedly falsified permits. "It was an absolute passion to actually make it in Cuba, where everything that is in the script happened, where the finca is where he lived, where his boat was, all the spots from the Morro castle to Cojimar where he fished. It's all here, so trying to duplicate it somewhere else was not very appealing."

The film stars the veteran stage and screen actor Adrian Sparks as Hemingway, with Giovanni Ribisi – best known for his roles in Avatar and Saving Private Ryan – as Denne Bart Petitclerc.

It is based on Petitclerc's memoir of the friendship that he developed with Hemingway after he wrote as a young reporter on the Miami Herald. Petitclerc later received a phone call – a scene included in the film – which he initially took to be a prank by one of his mates. "Good letter, kid," the famous voice growled, "you like to fish?"

For decades, films set on the island, including scenes in The Godfather Part II and Havana, a 1990 drama starring Robert Redford, were forced to use other locations – for Havana whole streets of the capital were recreated in the Dominican Republic.

This time the film crew had access to Hemingway's Finca Vigia near Havana, and the study where in 1951 he wrote the novella The Old Man and the Sea in an eight-week furious burst of creativity, an escape from years of ill health and depression. He called it "the best I can write ever for all of my life", and it won him the Pulitzer and Nobel prizes. Many of his best-known works were also written in Cuba, the home to which he returned as a sanctuary from often traumatic travels, such as his stint as a war correspondent including covering the D-Day landings, and several plane crashes in Africa.

He was initially relaxed about Fidel Castro's revolution, but left when he believed the new government would seize his beloved farm. The following year he killed himself at his new home in Idaho.

Other scenes were filmed in the former Government Palace, now a museum to Castro and the revolution, and the Grand Theatre – where one of Hemingway's favourite drinking holes, the bar of the Ambos Mundos hotel, was re-created. A gunfight between Castro's rebels and the soldiers of the rightwing dictator, Fugencio Batista, was filmed in the streets outside the theatre.

"It's been chaotic. Every day there's a new drama," said the British actor Joely Richardson, who plays Hemingway's fourth wife, Mary. "It's been so nutty. But you know what? It's up there with my best experiences. It's been fantastic."

Sparks said it was an extraordinary experience to work in the exact sites that Hemingway knew so well. "To be playing a section of the film where he's struggling with writer's block, I'm standing on exactly the square foot of ground that he stood on, with his typewriter in front of me, playing the scene. It wasn't acting, it was channelling. It was just allowing him to come through."

Papa, though intended for major commercial release, slid past the embargo by being technically classed as a documentary, because it is based on a true story.

The film production appears to be the latest small step towards an easing of tensions between Cuba and the United States. Soon after Castro seized power in 1959, Washington imposed an embargo on the island, which made it difficult for US firms to invest, trade or operate there. These sanctions were tightened further in 1996, when Congress passed the Helms–Burton Act that restricted US citizens from doing business in Cuba.

Those controls remain in place, which meant the film's producers had to get a licence to film in Cuba that included a cap on their spending on the island. But for filming to have been allowed at all is a breakthrough that would have been almost unthinkable 10 years ago.

Documentary film-makers have managed to continue working in Cuba, including for Wim Wenders's and Ry Cooder's Buena Vista Social Club, which made improbable worldwide stars of a group of older musicians from Havana.

In recent years, both countries have shown more flexibility in their dealings. Barack Obama has lifted almost all restrictions on Cuban-American travel and remittances, and encouraged education exchanges. Last year, the US president shook the hand of his Cuban counterpart, Raul Castro, at the funeral of Nelson Mandela, prompting the government in Havana to talk about the "beginning of the end of US aggressions".

Cuba, meanwhile, has loosened travel restrictions, encouraged more private enterprise, promised currency reforms and initiated a major project to build a free-trade zone at Mariel port. The state broadcaster has also begun showing baseball games from the US major leagues.

For Papa, the Cuban state film institute – ICAIC, which was founded soon after the revolution and is famed for its anti-imperialist classics – helped the US producers with locations, actors and costumes.

A full rapprochement is still some way off. But for those seeking closer relations, the film should be a gift because if there is one thing that these ideologically divided nations share, it is a love of Hemingway.