It should come as no surprise that the CIA’s finances are a secret. One of the rare glimpses into the agency’s funding came when Edward Snowden leaked a copy of the intelligence “black budget” to The Washington Post in 2013. But if history is any indication, the CIA may well have resources that don’t appear on any congressional document, highly classified or otherwise. Covert operations, by their very nature, often require access to off-the-books funding. The CIA’s first operation was paid for with funds seized from the Nazis, and in the years since, the agency has been notoriously creative about how it obtains its money.

Adnan Khashoggi would know. A “principal foreign agent” of the United States, as one Senate report referred to him, the billionaire playboy made a fortune (more than $100 million between 1970 and 1975 alone) from commissions negotiating arms deals with his native Saudi Arabia. He used these windfalls, in turn, to cultivate political clout—including, allegedly, with PresidentRichard Nixon. In the aftermath of Watergate, when Congress began reining in the CIA, Khashoggi helped establish the supranational intelligence partnership known as the Safari Club. Soon after, he aided the CIA in circumventing another congressional impediment. With money borrowed from the Saudi and U.S. intelligence-linked Bank of Credit and Commerce International, he financed the illegal arms sales that set off the Iran-Contra scandal.

One way Khashoggi structured his shadowy holdings during his heyday was through the specialized services of Mossack Fonseca, the law firm that is in the news for having helped global luminaries like Vladimir Putin hide their money. Thanks to a recent report from the International Consortium of Investigative Journalists, we now know Khashoggi to be among a number of former spies and CIA associates implicated by the 2.6 terabytes of offshore financial documents provided to the German newspaper Süddeutsche Zeitung last summer.

That his name should appear in an international dark money scandal suggests something about the nature of tax havens that much of the media’s coverage has thus far avoided grappling with. The Panama Papers have largely been presented as an unprecedented insight into how global elites hide their fortunes from tax collectors and other regulators. But they also underscore how tax havens are used by covert agencies and other shadowy players to launder dirty money, a practice that has a long history in which Panama, in particular, has played a notable part.

The Panama Papers date back to 1977. By then, the Carter administration, worried that it could jeopardize negotiations over the Panama Canal, had already willed itself into forgetting what the U.S. government had long known about Panama’s intimate role in the burgeoning South American cocaine trade. Serious allegations against Manuel Noriega, the intelligence chief who would go on to become the country’s ruler, had been brought to the attention of the now-defunct Bureau of Narcotics and Dangerous Drugs as early as 1971. But the United States’s interests in Panama were at least as strong as those of the emerging coke lords who were using Panama as a stopover for drug shipments headed north. In some cases, their interests were one and the same.

At the time, the Panama Canal Zone played host to the School of the Americas, the U.S. military training academy infamous for the remarkable array of atrocities committed by its highest-achieving graduates. Not far from the SOA facility was the classified U.S. communications network used to coordinate Operation Condor, the cross-border rendition, torture, execution, and assassination program implemented by the South American dictatorships of the era. With its abundance of U.S. surveillance hardware and constant influx of easily disguised foreigners, Panama became a sort of regional outpost for U.S. Cold War intelligence.

A proud SOA alumnus himself, Noriega was recruited by the U.S. Defense Intelligence Agency in 1959 and received his first check from the CIA in 1967. The military coup that broke out that year catapulted him to the top of Panama’s spy agency, a position for which the ruthless, ideologically flexible Noriega proved to be uniquely well-suited.

Noriega had a talent for the double life. He would fly to Washington to meet with CIA Director William Casey one day and to Havana to meet with Fidel Castro the next, positioning himself as a key interlocutor between the sworn enemies and playing one side off the other. He was just as comfortable railing against Yankee imperialism as he was serving up rivals and narco-associates in exchange for DEA commendations. Noriega allegedly charged $200,000 a planeload to protect the Medellin Cartel’s shipment routes. The $200,000 a year he collected from the Reagan administration must have seemed a pittance by comparison.

CIA payments to Noriega were channeled through accounts he maintained at the Bank of Credit and Commerce International, the agency’s preferred conduit for its secret dealings with Saudi and Pakistani intelligence and with theheroin-trafficking mujahedeen insurgency in Afghanistan. During the same period, Adnan Khashoggi, who was listed on a 1991 Defense Intelligence Report as having sold machine guns to the Medellin Cartel, was borrowing from the bank to finance weapons sales to Iran—the proceeds for which, like some of Noriega’s earnings, were then funneled to the Nicaraguan Contras. Subsequent federal prosecutions determined BCCI’s Panamanian branch, in particular, to be actively engaged in money laundering for the Colombian drug trade. A Senate subcommittee report called the bank a “fundamentally corrupt criminal enterprise.”

But BCCI was hardly the only Panamanian financial house awash in drug profits and covert intrigue. As a 1985 House Foreign Affairs report explained, it was hard to find a Panamanian bank that wasn’t engaged, to one degree or another, in some form of untoward activity. “With more than one hundred banks, the U.S. dollar as the national currency, and strict bank secrecy laws, Panama is an ideal haven for laundering narcotics money. Unlimited amounts of money may be brought into and out of the country with no reporting requirements, and money laundering is not a crime.” Corruption in government and the military, the committee found, was “endemic and institutionalized.”

Panama, to borrow the words of the Senate’s Iran-Contra report, had become the “hemisphere’s first ‘narco-kleptocracy,’” a major financial clearing house not just for the Colombian cartels, but for illegal groups of all stripes in the region, as well as “legitimate” businesspeople drawn to the exciting new services being offered thanks to the logistical demands and largesse of the drug trade. Americans were sinking millions into this innovative tax haven, and the surplus of available dirty currency actually insulated Panama from the debt crises that were sweeping the region at the time—converting it into a secure, relatively stable place for the Third World rich to hide their money.

“Particularly popular with Latin Americans,” writes Dr. Rachel Ehrenfeld in Evil Money, “was a double-shell arrangement, in which the Bahamian cover was overlaid with Panamanian corporate shells. Panamanian lawyers were equally adept at creating fictitious companies. The money would be wired from one corporate account to another without revealing the identity of the real owner.”

Dummy companies of this sort, set up by the White House and registered in Panama, were used to float the Nicaraguan Contras. Noriega’s personal Swiss-based lawyer even helped Marine Colonel Oliver North construct a front for an airfield in Costa Rica. A veritable fleet of aircraft, including planes provided by Noriega and some paid for through a BCCI account, made the circuitous journey from secret runway to secret runway, dropping off weapons in Honduras and Costa Rica, cocaine in the southern United States, and large stacks of small-denomination bills in Panamanian bank vaults.

As we continue to dig through the many layers of corruption, lawbreaking, and bad faith that have accumulated in the intervening years, it’s important to recognize that the quintessentially private practices that now form the basis for the Panama Papers revelations emerged within a context of large-scale state criminality.

The 1989 U.S. invasion that led to Noriega’s arrest only exacerbated the underlying problems of Panamanian governance. As Jonathan Marshall, co-author of the indispensable Cocaine Politics, explained, between “economic sanctions, capital flight, war damage, and a more than a billion dollars’ worth of damage from post-conflict looting,” any new president would have faced significant challenges. It happened that the one the United States installed, Guillermo Endara, had dubious ties to a bank the DEA and FBI both suspected of money laundering. Endara’s appointees for attorney general, treasury minister, and chief Supreme Court justice had each served as director of a bank shut down for its alliance with Colombia’s Cali Cartel. By the U.S. government’s own estimation, trafficking and laundering got worse in the invasion’s aftermath, a legacy that has continued on to the present day. Facing corruption charges, the country’s most recent president has sought refuge in Miami.

After the invasion, a joke started circulating around Panama that seems fairly prescient, in light of the Panama Papers. “They took Ali Baba,” it went, “and left us with the 40 thieves.”