Jeffrey Epstein tried to buy a multimillion-dollar palace in Morocco the day before his arrest in 2019, according to documents released by the US Department of Justice last month.
Epstein had pursued acquiring Bin Ennakhil since 2011, but disputes with the seller over the price and purchase arrangement dragged on for years.
The grand palace in the luxury Palmeraie neighbourhood of Marrakech has been described as an architectural masterpiece, built by 1,300 craftsmen and featuring ornate carvings and mosaics.
Epstein signed a $14.95m (£11m) wire transfer on 5 July 2019, the day before his arrest, following an agreement to buy the offshore company that owned the property for €18m (£13.3m).
According to the released documents, the transfer was Epstein's last major financial transaction in the period before his arrest by US authorities on sex trafficking charges upon his return to New York.
Three days after the arrest, Epstein's accountant Richard Kahn cancelled the wire transfer and the purchase was ultimately never completed.
Morocco has no extradition treaty with the US and local media has speculated that one of Epstein's motivations to purchase the property may have been to retreat to the country to avoid arrest, if new charges were brought against him.
However, a former associate of Epstein, who preferred not to be named, said the transaction showed Epstein "had no clue" about his imminent arrest.
They added that "it would make sense if he was thinking of a potential sanctuary where he could still live like a king".
The released files, however, contain no reference to Epstein discussing the country as a possible refuge from US authorities.
Epstein's connections to Morocco go back to at least the early 2000s, with Virginia Giuffre, one of his most prominent accusers, recounting in her memoir of being flown to Tangier by Epstein and Ghislaine Maxwell to inspect the interior design of a number of luxury properties.
At the time, Epstein wanted to redesign parts of his island home in a Moroccan style.
In 2002, Epstein attended the wedding of Moroccan King Mohammed with Maxwell, having been invited by former US President Bill Clinton.
Epstein was convicted in the United States of soliciting underage sex in 2008, and following his release from house arrest in 2010 his interest in Morocco seems to have grown.
The released files appear to show that in the same year, Epstein asked former Labour cabinet minister Peter Mandelson to find him an assistant who could "fin[d] a house in Marrakesh" for him.
The documents detail how Epstein made periodic visits to Morocco from 2012, staying in the exclusive Palmeraie district, home to a wealthy community of expatriates including Jabor al Thani of the Qatari royal family, a close associate whom he described as his "Arab brother".
Being mentioned or pictured in the Epstein files is not, in itself, an indication of wrongdoing.
Epstein's long-term girlfriend Karyna Shuliak began leading the search for a property in Marrakech, with numerous visits and negotiations documented in emails under her name.
Marc Leon, a partner of Kensington Luxury Properties, told the BBC that Epstein's focus settled on their property Bin Ennakhil - Arabic for "between the palm trees" - as early as 2011.
At that time, Epstein thought the palace, owned by German waste magnate Gunter Kiss, was overvalued at €55m and his initial offer was so low that Kiss was offended and refused to deal with Epstein again, the source who was close to Epstein told the BBC.
Subsequently, Epstein used his girlfriend Shuliak and his network of contacts in Morocco to conduct further inspections of the property. In 2018, Epstein himself visited the property before Shuliak made final bids on the property while pretending to be acting on behalf of Leon Black, a billionaire investor friend of Epstein.
Ultimately, it became clear that Epstein was the real prospective buyer but the seller "Mr Kiss" - as he is known in the emails - agreed to continue the negotiations, according to the documents and the source close to Epstein.
Inside the Moroccan palace that caught Epstein's eye:
The files show that, at one stage, Kensington Luxury Properties proposed to Epstein a "sale and tax strategy", whereby the property would be registered with the Moroccan authorities as sold for €10m while a transaction of €20m would take place for the shares of an offshore company that owned the property.
The arrangement would have allowed Epstein to register his name on the title deeds of the property while reducing the tax he would pay to Moroccan authorities.
However, Kensington Luxury Properties denied to the BBC that there was an unethical or illegal attempt to minimise tax.
"This transaction did not violate any tax regulations," Mr Leon told the BBC. "Mr Epstein wanted to pay registration fees in Morocco, even though he was under no obligation to do so... in order to own the property in his own name."
The property company was at the time the local real estate representative of the renowned UK-based auction house Christie's.
Ultimately, Epstein decided to purchase the property solely by paying for the shares of the offshore company and was in the process of determining how to register it in Morocco at the time of his 2019 arrest.