Last month a three-year-long federal prosecution of Blackwater collapsed. The government’s 15-felony indictment—on such charges as conspiring to hide purchases of automatic rifles and other weapons from the Bureau of Alcohol, Tobacco, Firearms, and Explosives—could have led to years of jail time for Blackwater personnel. In the end, however, the government got only misdemeanor guilty pleas by two former executives, each of whom were sentenced to four months of house arrest, three years’ probation, and a fine of $5,000. Prosecutors dropped charges against three other executives named in the suit and abandoned the felony charges altogether.

But the most noteworthy thing about the largely failed prosecution wasn’t the outcome. It was the tens of thousands of pages of documents—some declassified—that the litigation left in its wake. These documents illuminate Blackwater’s defense strategy—and it’s a fascinating one: to defeat the charges it was facing, Blackwater built a case not only that it worked with the CIA—which was already widely known—but that it was in many ways an extension of the agency itself.

Founded in 1997 by Erik Prince, heir to an auto-parts family fortune, Blackwater had proved especially useful to the CIA in the early 2000s. “You have to remember where the CIA was after 9/11,” says retired Congressman Pete Hoekstra, who served as the Republican chairman of the House Permanent Select Committee on Intelligence from 2004 to 2006 and later as the ranking member of the committee. “They were gutted in the 1990s. They were sending raw recruits into Afghanistan and other dangerous places. They were looking for skills and capabilities, and they had to go to outside contractors like Blackwater to make sure they could accomplish their mission.”

But according to the documents Blackwater submitted in its defense—as well as an email exchange I had recently with Prince—the contractor’s relationship with the CIA was far deeper than most observers thought. “Blackwater’s work with the CIA began when we provided specialized instructors and facilities that the Agency lacked,” Prince told me recently, in response to written questions. “In the years that followed, the company became a virtual extension of the CIA because we were asked time and again to carry out dangerous missions, which the Agency either could not or would not do in-house.”

A prime example of the close relationship appears to have unfolded on March 19, 2005. On that day, Prince and senior CIA officers joined King Abdullah of Jordan and his brothers on a trip to Blackwater headquarters in Moyock, North Carolina, according to lawyers for the company and former Blackwater officials. After traveling by private jet from Washington to the compound, Abdullah (a former Jordanian special-forces officer) and Prince (a former Navy SEAL) participated in a simulated ambush, drove vehicles on a high-speed racetrack, and raided one of the compound’s “shoot houses,” a specially built facility used to train warriors in close-quarters combat with live ammo, Prince recalls.

At the end of the day, company executives presented the king with two gifts: a modified Bushmaster AR-15 rifle and a Remington shotgun, both engraved with the Blackwater logo. They also presented three Blackwater-engraved Glock pistols to Abdullah’s brothers. According to Prince, the CIA asked Blackwater to give the guns to Abdullah “when people at the agency had forgotten to get gifts for him.”

Three years later, the ATF raided the Moyock compound. In itself, this wasn’t unusual; the ATF had been conducting routine inspections of the place since 2005, when Blackwater informed the government that two of its employees had stolen guns and sold them on the black market. Typically, agents would show up in street clothes, recalled Prince. “They knew our people and our processes.”

But the 2008 visit, according to Prince, was different. “ATF agents had guns drawn and wore tactical jackets festooned with the initials ATF. It was a cartoonish show of force,” he said. (Earl Woodham, a spokesman for the Charlotte field division of the ATF, disputes this characterization. “This was the execution of a federal search warrant that requires they be identified with the federal agency,” he says. “They had their firearms covered to execute a federal search warrant. To characterize this as anything other than a low-key execution of a federal search warrant is inaccurate.”)

During the raid, the ATF seized 17 Romanian AK-47s and 17 Bushmaster AR-13 rifles the bureau claimed were purchased illegally through the sheriff’s office in Camden County, North Carolina. It also alleged that Blackwater illegally shortened the barrels of rifles and then exported them to other countries in violation of federal gun laws. Meanwhile, in the process of trying to account for Blackwater’s guns, the ATF discovered that the rifles and pistols presented in 2005 to King Abdullah and his brothers were registered to Blackwater employees. Prosecutors would subsequently allege that Gary Jackson—the former president of Blackwater and one of the two people who would eventually plead guilty to a misdemeanor—had instructed employees to falsely claim on ATF forms that the guns were their own personal property and not in the possession of Jordanian royalty.

In all of these instances—the purchase of the rifles through the Camden County sheriff, the shipment of the guns to other countries, and the gifts to Abdullah—Blackwater argued that it was acting on behalf of the U.S. government and the CIA. All of these arguments, obviously, were very much in Blackwater’s legal interest. That said, it provided the court with classified emails, memoranda, contracts, and photos. It also obtained sealed depositions from top CIA executives from the Directorate of Operations, testifying that Blackwater provided training and weapons for agency operations. (A CIA spokesman declined to comment for this story.)

One document submitted by the defense names Jose Rodriguez, the former CIA chief of the Directorate of Operations, and Buzzy Krongard, the agency’s former executive director, as among those CIA officers who had direct knowledge of Blackwater’s activities, in a section that is still partially redacted. This document is the closest Blackwater has come to acknowledging that Prince himself was a CIA asset, something first reported in 2010 by Vanity Fair. One of the names on the list of CIA officers with knowledge of Blackwater’s work in the document is “Erik P”—with the remaining letters whited out.

This document made Blackwater’s defense clear: “the CIA routinely used Blackwater in missions throughout the world,” it said. “These efforts were made under written and unwritten contracts and through informal requests. On many occasions the CIA paid Blackwater nothing for its assistance. Blackwater also employed CIA officers and agents, and provided cover to CIA agents and officers operating in covert and clandestine assignments. In many respects, Blackwater, or at least portions of Blackwater, was an extension of the CIA.”

When I asked Prince why Blackwater would often work for free, he responded, “I agreed to provide some services gratis because, in the wake of 9/11, I felt it my patriotic duty. I knew that I had the tools and resources to help my country.”

Moreover, according to still-sealed testimony described to The Daily Beast, the agency had its own secure telephone line and a facility for handling classified information within Blackwater’s North Carolina headquarters. CIA officers trained there and used an area—fully shielded from view inside the rest of the Blackwater compound by 20-foot berms—to coordinate operations.

In the wake of the major charges being dropped, the U.S. attorney who prosecuted the case against Blackwater, Thomas Walker, told me that it would be wrong to dismiss the prosecution as a waste of time. “The company looks completely different now than before the investigation,” he said. “For example, in 2009, Erik Prince was the sole owner. This company now has a governing board that is accountable.”

In 2010 Prince sold Blackwater, which is now known as Academi, for an estimated $200 million. Prince retains control of numerous companies that were part of Blackwater before he sold it, but he told me that he had “ceased providing any services” to the U.S. government.

Walker would not discuss Blackwater’s relationship with the CIA. But he did say the defense that the company was acting for the government did not excuse any violations of federal law. “Our evidence showed there was a mentality at the company that they considered themselves above the law,” Walker said. “That is a slippery slope. There came a time when there had to be accountability at Blackwater.”

David Boies, the lawyer who represented Al Gore in Bush v. Gore, took up Gary Jackson’s case last fall. Boies told me he did so because he saw the prosecution as an abuse of power. “These people were functioning really as an arm of the CIA at a time when the CIA’s resources were strained,” he said. “I think that Erik Prince and Mr. Jackson and other people at Blackwater thought they were being patriots.”

Reflecting on the prosecution and the scrutiny of the company he founded, Prince said the charges against Blackwater executives left him “perplexed and angry.” “Blackwater carried out countless life-threatening missions for the CIA,” he said. “And, in return, the government chose to prosecute my people for doing exactly what was asked of them.”

Correction: An earlier version of this article incorrectly characterized the model of gun given to the king. It was a Bushmaster AR-15 rifle.

Correction: This article originally stated that Prince retains control of numerous companies affiliated with Academi. In fact, those companies are not affiliated with Academi.